kavindu
Newbie level 1
Hi All,
I am new to PIC programming. I programme a thermostat using LM35. Now I want to update it with a relay which have a adjustable setpoint. I mean If I need a relay output at 25 C I can adjust it so.
IF I need it at 23C It should be at there.
I have RC2 & RC3 as input (push buttons) and RC5 as output in 16F876A in my hardwere.
This is my code for thermostat.
PLS............... Help me........ my code is compile. Ineed it to be update with a output relay output. I mean It shows temparature but not relay output. I need it with a adjustable relay setpoint.
/**************************************************************
THERMOMETER WITH LM35 & LCD DISPLAY
====================================
Date: July 2011
File: LM35.C
**************************************************************/
//
// Start of MAIN Program. Configure LCD and A/D converter
//
void main()
{
unsigned long Vin,tmp;
char * ch ="00.0";
TRISB = 0; // PORTC are outputs (LCD)
TRISA = 0xFF; // PORTA is input
//
// Configure LCD
//
Lcd_Init(&PORTB); // LCD is connected to PORTC
Lcd_Cmd(LCD_CLEAR);
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Out(1,3,"THERMO METER");
Delay_ms(500); // delay
ADCON1 = 0x80; // Use AN0 and Vref=+5V
//
//
// Program loop
//
for(; // Endless loop
{
Lcd_Cmd(LCD_CURSOR_OFF);
Vin = Adc_Read(0); //read ADC(0)
tmp = Vin/2 ;
ch[0] = (tmp / 10 + 48) ; //Calculate fractional part
ch[1] = (tmp % 10 + 48) ;
Lcd_Chr(2,11,223);
Lcd_Chr(2,12,'C');
Lcd_out(2,7,ch);
Delay_ms(500); // Wait 1 second
}
}
I am new to PIC programming. I programme a thermostat using LM35. Now I want to update it with a relay which have a adjustable setpoint. I mean If I need a relay output at 25 C I can adjust it so.
IF I need it at 23C It should be at there.
I have RC2 & RC3 as input (push buttons) and RC5 as output in 16F876A in my hardwere.
This is my code for thermostat.
PLS............... Help me........ my code is compile. Ineed it to be update with a output relay output. I mean It shows temparature but not relay output. I need it with a adjustable relay setpoint.
/**************************************************************
THERMOMETER WITH LM35 & LCD DISPLAY
====================================
Date: July 2011
File: LM35.C
**************************************************************/
//
// Start of MAIN Program. Configure LCD and A/D converter
//
void main()
{
unsigned long Vin,tmp;
char * ch ="00.0";
TRISB = 0; // PORTC are outputs (LCD)
TRISA = 0xFF; // PORTA is input
//
// Configure LCD
//
Lcd_Init(&PORTB); // LCD is connected to PORTC
Lcd_Cmd(LCD_CLEAR);
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Out(1,3,"THERMO METER");
Delay_ms(500); // delay
ADCON1 = 0x80; // Use AN0 and Vref=+5V
//
//
// Program loop
//
for(; // Endless loop
{
Lcd_Cmd(LCD_CURSOR_OFF);
Vin = Adc_Read(0); //read ADC(0)
tmp = Vin/2 ;
ch[0] = (tmp / 10 + 48) ; //Calculate fractional part
ch[1] = (tmp % 10 + 48) ;
Lcd_Chr(2,11,223);
Lcd_Chr(2,12,'C');
Lcd_out(2,7,ch);
Delay_ms(500); // Wait 1 second
}
}
Last edited: