Mithun_K_Das
Advanced Member level 3

- Joined
- Apr 24, 2010
- Messages
- 899
- Helped
- 24
- Reputation
- 48
- Reaction score
- 27
- Trophy points
- 1,318
- Location
- Dhaka, Bangladesh, Bangladesh
- Activity points
- 8,254
I'm planning to design a LCD voltmeter using atmega8. So I started with c program in microCpro.
Here is the code:
// LCD module connections
unsigned int adc_rd;
sbit LCD_RS at PORTD2_bit;
sbit LCD_EN at PORTD3_bit;
sbit LCD_D4 at PORTD4_bit;
sbit LCD_D5 at PORTD5_bit;
sbit LCD_D6 at PORTD6_bit;
sbit LCD_D7 at PORTD7_bit;
sbit LCD_RS_Direction at DDD2_bit;
sbit LCD_EN_Direction at DDD3_bit;
sbit LCD_D4_Direction at DDD4_bit;
sbit LCD_D5_Direction at DDD5_bit;
sbit LCD_D6_Direction at DDD6_bit;
sbit LCD_D7_Direction at DDD7_bit;
// End LCD module connections
char txt1[] = "Voltage = ";
char txt2[] = adc_rd;
char i; // Loop variable
void Move_Delay() { // Function used for text moving
Delay_ms(10); // You can change the moving speed here
}
void main()
{
while(1)
{
adc_rd = ADC_Read(0);
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,txt1); // Write text in first row
Lcd_Out(2,1,txt2); // Write text in second row
Delay_ms(100);
Lcd_Cmd(_LCD_CLEAR); // Clear display
}
}
But the problem is I can not configure the LCD to get the reading of ADC(0) to the display.
I need help. Please see the marked line first.
Thanks
MKDas
Here is the code:
// LCD module connections
unsigned int adc_rd;
sbit LCD_RS at PORTD2_bit;
sbit LCD_EN at PORTD3_bit;
sbit LCD_D4 at PORTD4_bit;
sbit LCD_D5 at PORTD5_bit;
sbit LCD_D6 at PORTD6_bit;
sbit LCD_D7 at PORTD7_bit;
sbit LCD_RS_Direction at DDD2_bit;
sbit LCD_EN_Direction at DDD3_bit;
sbit LCD_D4_Direction at DDD4_bit;
sbit LCD_D5_Direction at DDD5_bit;
sbit LCD_D6_Direction at DDD6_bit;
sbit LCD_D7_Direction at DDD7_bit;
// End LCD module connections
char txt1[] = "Voltage = ";
char txt2[] = adc_rd;
char i; // Loop variable
void Move_Delay() { // Function used for text moving
Delay_ms(10); // You can change the moving speed here
}
void main()
{
while(1)
{
adc_rd = ADC_Read(0);
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,txt1); // Write text in first row
Lcd_Out(2,1,txt2); // Write text in second row
Delay_ms(100);
Lcd_Cmd(_LCD_CLEAR); // Clear display
}
}
But the problem is I can not configure the LCD to get the reading of ADC(0) to the display.
I need help. Please see the marked line first.
Thanks
MKDas