mr_byte31
Full Member level 5
Hi All,
I made a small project to read ADC results and get their difference.
My MCU Atmega328p. Compiler MikroC 7
the problem is with LCD :
the output looks like :
when I initialize the first variables, it works fine
any comment ?
I made a small project to read ADC results and get their difference.
My MCU Atmega328p. Compiler MikroC 7
the problem is with LCD :
Code:
sbit LCD_RS at PORTD0_bit;
sbit LCD_EN at PORTD1_bit;
sbit LCD_D4 at PORTD2_bit;
sbit LCD_D5 at PORTD3_bit;
sbit LCD_D6 at PORTD4_bit;
sbit LCD_D7 at PORTD5_bit;
sbit LCD_RS_Direction at DDD0_bit;
sbit LCD_EN_Direction at DDD1_bit;
sbit LCD_D4_Direction at DDD2_bit;
sbit LCD_D5_Direction at DDD3_bit;
sbit LCD_D6_Direction at DDD4_bit;
sbit LCD_D7_Direction at DDD5_bit;
void main()
{
unsigned int Adc_0,Adc_1;
int Adc_diff=0;
char strArray[16]= "0123456789";
LCD_Init();
ADC_Init();
Lcd_Cmd(_LCD_CLEAR);
LCD_Cmd(_LCD_CURSOR_OFF);
while(1)
{
LCD_Out(1,1,"Moh v3 :");
Adc_0 = ADC_Read(0);
Adc_1 = ADC_Read(1);
Adc_diff = Adc_0 - Adc_1;
if(Adc_diff < 0)
{
Adc_diff = Adc_diff *-1;
}
LCD_Chr(2,1,strArray[Adc_diff/1000%10]);
LCD_Chr(2,2,strArray[Adc_diff/100%10]);
LCD_Chr(2,3,strArray[Adc_diff/10%10]);
LCD_Chr(2,4,strArray[Adc_diff/1%10]);
}
}
when I initialize the first variables, it works fine
Code:
unsigned int Adc_0=0,Adc_1=0;
any comment ?
Last edited: