Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
program sourcecode
symbol Selected = PORTA.0
symbol HrChange = PORTA.1
symbol MinChange = PORTA.2
symbol SecChange = PORTA.3
symbol Hr1224 = PORTA.4
symbol led1224 = PORTA.5
dim data7, num7 as byte
dim temp as byte
dim hr, min, sec as byte
dim hrten1224, hrone1224 as byte
dim HRTEN, HRONE, MINTEN, MINONE, SECTEN,SECONE as byte
sub procedure interrupt
temp = temp + 1
PIR1.TMR1IF = 0
T1CON.TMR1ON = 0
TMR1H = $3C
TMR1L = $AF
T1CON.TMR1ON = 1
PORTA.3 = 1
end sub
sub procedure delay1ms
delay_ms(1)
end sub
sub procedure delay50ms
delay_ms(50)
end sub
sub procedure send7 (dim value, seven as byte)
PORTC = 0
select case value
case 0 data7 = $C0
case 1 data7 = $F9
case 2 data7 = $A4
case 3 data7 = $B0
case 4 data7 = $99
case 5 data7 = $92
case 6 data7 = $82
case 7 data7 = $F8
case 8 data7 = $80
case 9 data7 = $90
end select
PORTB = data7
select case seven
case 1 num7 = 1
case 2 num7 = 2
case 3 num7 = 4
case 4 num7 = 8
case 5 num7 = 16
case 6 num7 = 32
end select
PORTC = num7
end sub
main:
TRISB = 0
PORTB = 0
TRISC = 0
PORTC = 0
ADCON1 = 7
TRISA = $1F
T1CON = 0
TMR1H = $3C
TMR1L = $AF
PIR1.TMR1IF = 0
PIE1.TMR1IE = 1
INTCON.GIE = 1
INTCON.PEIE = 1
T1CON.TMR1ON = 1
while true
if Selected then
T1CON.TMR1ON = 0
if Hr1224 then
delay50ms
hrten1224 = 1
hrone1224 = 3
led1224 = 1
else
hrten1224 = 0
hrone1224 = 1
led1224 = 0
end if
if HrChange then
delay50ms
HRONE = HRONE + 1
if (HRONE > 9) then
HRONE = 1
HRTEN = HRTEN + 1
end if
if (HRTEN > hrten1224) and (HRONE > hrone1224) then
HRTEN = 0
HRONE = 0
end if
while HrChange
wend
end if
if MinChange then
delay50ms
MINONE = MINONE + 1
if (MINONE > 9) then
MINONE = 0
MINTEN = MINTEN + 1
end if
if (MINTEN > 5) then
MINTEN = 0
MINONE = 0
end if
while MinChange
wend
end if
if SecChange then
delay50ms
SECONE = SECONE + 1
if (SECONE > 9) then
SECONE = 0
SECTEN = SECTEN + 1
end if
if (SECTEN > 5) then
SECTEN = 0
SECONE = 0
end if
while SecChange
wend
end if
else
T1CON.TMR1ON = 1
end if
if (temp = 20) then
temp = 0
sec = sec + 1
SECONE = SECONE + 1
end if
if (SECONE > 9) then
SECONE = 0
SECTEN = SECTEN + 1
end if
if (SECTEN > 5) then
SECTEN = 0
SECONE = 0
MINONE = MINONE + 1
end if
if (MINONE > 9) then
MINONE = 0
MINTEN = MINTEN + 1
end if
if (MINTEN > 5) then
MINTEN = 0
MINONE = 0
HRONE = HRONE + 1
end if
if (HRONE > 9) then
HRONE = 0
HRTEN = 1
end if
if (HRTEN > hrten1224) and (HRONE > hrone1224) then
HRTEN = 0
HRONE = 0
MINTEN = 0
MINONE = 0
SECTEN = 0
SECONE = 0
end if
send7(HRTEN, 1)
delay1ms
send7(HRONE, 2)
delay1ms
send7(MINTEN, 3)
delay1ms
send7(MINONE, 4)
delay1ms
send7(SECTEN, 5)
delay1ms
send7(SECONE, 6)
delay1ms
wend
end.
unsigned long ADCResult;
unsigned int value[3];
char vstring[3];
void GlobInit(void){
TRISB = 0;
PORTB = 0;
TRISA = 1;
ADCON1 = 0x4E;
LCD_Config(&PORTB, 4, 5, 6, 3, 2, 1, 0);
LCD_Cmd(LCD_CLEAR);
LCD_Cmd(LCD_CURSOR_OFF);
LCD_Out(1, 1, "Temp:");
LCD_Out(1, 15, "'C");
}
void main(){
GlobInit();
while (1){
ADCResult = (ADC_Read(0) * 500) >> 10;
value[0] = ADCResult / 100;
value[1] = (ADCResult / 10) % 10;
value[2] = ADCResult % 10;
vstring[0] = value[0] + 48;
vstring[1] = value[1] + 48;
vstring[2] = value[2] + 48;
LCD_Out(1, 10, vstring);
delay_ms(50);
}
}
program thermometer452
dim LCD_RS as sbit at RB4_bit
LCD_EN as sbit at RB5_bit
LCD_D4 as sbit at RB0_bit
LCD_D5 as sbit at RB1_bit
LCD_D6 as sbit at RB2_bit
LCD_D7 as sbit at RB3_bit
LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
dim ADCResult as longword
dim value as word[3]
dim vstring as string[3]
sub procedure GlobInit
TRISB = 0
PORTB = 0
TRISA = 1
ADCON1 = $4E
LCD_Init
LCD_Cmd(_LCD_CLEAR)
LCD_Cmd(_LCD_CURSOR_OFF)
LCD_Out(1, 1, "Temp:")
LCD_Out(1, 15, "'C")
end sub
main:
GlobInit
while true
ADCResult = (ADC_Read(0) * 500) >> 10
value[0] = ADCResult div 100
value[1] = (ADCResult div 10) mod 10
value[2] = ADCResult mod 10
vstring[0] = value[0] + 48
vstring[1] = value[1] + 48
vstring[2] = value[2] + 48
LCD_Out(1, 10, vstring)
delay_ms(50)
wend
end.
The circuit should have a temperatur sensor, I think, presently it doesn't. You also should know, how you want to reseti have to display maximum temperature and minimum temperature on the LCD
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 unsigned oldstate0; unsigned oldstate1; unsigned tMax,tMin; unsigned temp_value; char out[12],out2[12]; // declares array of 12 characters float dec_value; void loop1() { Lcd_Out(1,1,"Welcome to ECE"); //Prints text on LCD at 1st row and 1st column Lcd_Chr(2,7,out[3]); //Prints on LCD at 2nd row and 3rd column Lcd_Chr_Cp(out[4]); Lcd_Chr_Cp('.'); //Prints decimal point on LCD Lcd_Out(2,10,out2); //Prints reminder on LCD at 2nd row and 6th column Lcd_Chr_Cp(223); //Prints degree symbol on LCD at 2nd row and 7th column Lcd_Chr_Cp('C'); //Prints Celsius symbol delay_ms(3000); // Sample at 3 sec } void main() { ADCON1 = 0x80; // Configure analog input TRISA = 0xFF; // PORTA as input TRISB = 0x00; // PORTB as ouput Lcd_Init(&PORTB); //Initialise LCD with PORT B Lcd_Cmd(LCD_CLEAR); // Clear LCD Lcd_Cmd(LCD_CURSOR_OFF); do { temp_value = (Adc_Read(0)/2); // Read analog input WordToStr(temp_value,out); // convert hex to string dec_value = (adc_read(0)%10); //get the remainder so that it can display the up to 1 decimal place floattostr(dec_value,out2); // //remove blank spaces if (temp_value > tMax) { tMax = temp_value; } if (temp_value < tMin) { tMin = temp_value; } if ( Button(&PORTA,0,10,1 )) oldstate0 = 1 ; if ( oldstate0 && Button(&PORTA,1,10,0 )) { Lcd_Init(&PORTB); Lcd_Out(2,1,"Max"); loop1(); } if ( Button(&PORTA,0,10,1 )) oldstate1 = 1 ; if ( oldstate1 && Button(&PORTA,0,10,0 )) { { Lcd_Init(&PORTB); Lcd_Out(2,1,"Min"); loop1(); } } } while(1); }