include mega16 asm equ __lcd_port 0x15 PORTC endasm include lcd4x40 in

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <mega16.h>
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd4x40.h>
#include <delay.h>
#include <stdio.h>
#define ADC_VREF_TYPE 0xC0
char lcd_buffer[40];
int temp;
unsigned int read_adc(unsigned char adc_input)
{
unsigned int ADC=0;
ADMUX=adc_input|ADC_VREF_TYPE;
ADCSRA|=0x40;
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
ADC=ADCL;
ADC|=(int)ADCH << 8;
return ADC;
}
void main(void)
{
PORTA=0x00;
DDRA=0x00;
PORTB=0x00;
DDRB=0x00;
PORTC=0x00;
DDRC=0xFF;
PORTD=0x00;
DDRD=0x00;
lcd_init();
lcd_clear();
while (1)
{
temp=read_adc(0);
lcd_clear();
sprintf(lcd_buffer,"%.0f",temp); //u can write u caracter on "..UP..Max 16 carakter /n.....Down Max 16 caracter"
lcd_puts(lcd_buffer);
delay_ms(1000);
lcd_clear();
};
}