dabby21
Advanced Member level 4
- Joined
- Aug 8, 2011
- Messages
- 114
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,296
- Location
- Philippines
- Activity points
- 2,232
sirs,
good day,
im working a simulation on LM35 through pic and output the results in LCD.
upon researching, i have come up the above code, outputting the string temperature and character to the LCD was good, but when i try to change the result of LM35 in protues, it does not change the result on the LCD.\
heres my simulation on proteus sirs. thanks in advance
good day,
im working a simulation on LM35 through pic and output the results in LCD.
Code:
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
float temp;
char i,txt[15];
unsigned int temp_res;
unsigned int quanta=0.488;
void Move_Delay() { // Function used for text moving
Delay_ms(500); // You can change the moving speed here
}
void main(){
ADCON1 = 0x0E;
ADCON0 = 0x00; // Set PORTA.0 To analog And all others digital
ADCON2 = 0x8A; // Set PORTA analog And right justify result
TRISA = 0xFF;
TRISB = 0x00;
PORTB = 0x00;
LATB = 0x00;
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
ADC_Init(); // Initialize ADC
do{
temp_res = ADC_Read(0);
temp= temp_res * quanta;
FloatToStr(temp, txt); // Convert temperature to string
Lcd_Out(2,3,txt);
Delay_Ms(300);
} while(1);
/* Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,6,txt3); // Write text in first row
Lcd_Out(2,6,txt4); // Write text in second row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,1,txt1); // Write text in first row
Lcd_Out(2,5,txt2); // Write text in second row
Delay_ms(2000);
// Moving text
for(i=0; i<4; i++) { // Move text to the right 4 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
while(1) { // Endless loop
for(i=0; i<8; i++) { // Move text to the left 7 times
Lcd_Cmd(_LCD_SHIFT_LEFT);
Move_Delay();
}
for(i=0; i<8; i++) { // Move text to the right 7 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
} */
}
upon researching, i have come up the above code, outputting the string temperature and character to the LCD was good, but when i try to change the result of LM35 in protues, it does not change the result on the LCD.\
heres my simulation on proteus sirs. thanks in advance