I need help here.. im try to run my coding which i want to show on lcd. but i dont know how to make a coding so that lcd will show each reading one after another..start with temperature then moisture followed by carbon. but from my coding below,it juz read temperature..totally need your help
- CODE: SELECT_ALL_CODE
/*
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
// Set VREF according to the voltage reference :
// 5.00 - power supply jumper set to 5V position (reference = 5V)
// 3.30 - power supply jumper set to 3.3V position (reference = 3.3V)
const unsigned short VREF = 5.0;
unsigned int temp_res;
float temp;
int carbon_mono ;
int moist_read;
char txt[15];
int ANCON0 ; // Configure PORTB pins as digital
int ANCON1 ; // Configure RE1 pin as analog
int ANCON2 ;
int ANSEL3_bit;
int ANSEL2_bit;
int ANSEL1_bit;
void main() {
ANCON0 = 0x00; // Configure PORTB pins as digital
ANCON1 = 0x00; // Configure RE1 pin as analog
ANCON2 = 0x00;
ANSEL3_bit = 1;
ANSEL2_bit =1 ;
ANSEL1_bit=1;
TRISA3_bit = 1; // Configure RA3 pin as input
TRISA2_bit = 1;
TRISA1_bit=1;
ADC_Init(); // Initialize ADC
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, "Temperature :");
Lcd_Chr(2,8,223); // Different LCD displays have different
// char code for degree
Lcd_Chr(2,9,'C'); // Display "C" for Celsius
temp_res = 0;
do {
temp_res = ADC_Get_Sample(3); // Get 10-bit results of AD conversion
temp = (temp_res * VREF)/100; // Calculate temperature in Celsuis
// change Vref constant according
// to the power supply voltage
FloatToStr(temp, txt); // Convert temperature to string
txt[4] = 0;
Lcd_Out(2,3,txt); // Write string in second row
Delay_ms(1000);
} while(1);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, "Carbon Monoxide :");
carbon_mono = 0;
do {
carbon_mono = ADC_Get_Sample(3); // Get 10-bit results of AD conversion
FloatToStr(carbon_mono, txt); // Convert to string
txt[4] = 0;
Lcd_Out(2,3,txt); // Write string in second row
Delay_ms(1000);
} while(1);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, "Moisture :");
moist_read = 0;
do {
moist_read = ADC_Get_Sample(3); // Get 10-bit results of AD conversion
FloatToStr(moist_read, txt);
txt[4] = 0;
Lcd_Out(2,3,txt); // Write string in second row
Delay_ms(1000);
} while(1);
}