Ok thank you for the helpful ideas I've used those ideas now I want to incorporate an LED alarm that when the temp gets to >=80 degrees F that the LED 0 will flash and I won't be able to turn the alarm off until the temp goes below 80 degrees and switch 2 has been pressed.
Below I have the code that I've tried to put into the microcontroller but everytime i try to do something I get caught up with no display on the LCD, any help would be appreciated.
Code:DEFINE LCD_DREG PORTD 'data register DEFINE LCD_RSREG PORTE 'register select DEFINE LCD_RSBIT 0 'pin number DEFINE LCD_EREG PORTE 'enable register DEFINE LCD_EBIT 1 'enable bit DEFINE LCD_RWREG PORTE 'read/write register DEFINE LCD_RWBIT 2 'read/write bit DEFINE LCD_BITS 8 'width of data DEFINE LCD_LINES 2 'lines in display DEFINE LCD_COMMANDUS 2000 'delay in micro seconds DEFINE LCD_DATAUS 20 'delay in micro seconds 'Set the port directions. We are setting PORTA.0 to an input, all rest outputs 'all of PORTD is set to outputs to run the LCD 'and all of PORTE as outputs even though PORTE has only 3 lines. TRISA = %11111111 'set PORTA lines TRISB = %00101111 TRISD = %00000000 'set all PORTD lines to output TRISE = %00000000 'set all PORTE lines to output ADCON1=%10000010 'see discussion above OPTION_REG.7=0 'Define the variables used ADVAL VAR BYTE 'create ADVAL to store result TEMP VAR BYTE 'temperature Farenheit variable TEMPC VAR BYTE 'temperature Celsius variable DEG CON 223 'write an degree mark on lcd MODE VAR BIT C CON 1 F CON 0 LED VAR BYTE 'define the adcin parameters DEFINE ADC_BITS 10 'Set number of bits in result DEFINE ADC_CLOCK 3 'Set clock source (3=rc) DEFINE ADC_SAMPLEUS 50 'Set sampling time in uS PAUSE 500 LCDOUT $FE, 1 'clear screen PORTB.4=0 PORTB.5=0 MODE=C LOOP: 'The main loop of the program ADCIN 4, ADVAL 'Read channel 0 to adval ADVAL =(ADVAL*/500)>>2 TEMP=ADVAL TEMPC=((TEMP-32) *100) /180 IF TEMP<32 THEN TEMP=32 IF TEMP>100 THEN TEMP=100 IF TEMP>=80 THEN GOSUB FLASH IF PORTB.0=0 THEN MODE=MODE^1 WHILE PORTB.0=0 : WEND PAUSE 50 ENDIF PAUSE 100 LCDOUT $FE, 1, "TEMP=" 'go to home position IF MODE=F THEN LCDOUT DEC3 TEMPC,DEG, "C" 'print to line 1 of 2 line display ELSE LCDOUT DEC3 TEMP,DEG, "F" ENDIF GOTO LOOP END FLASH: PAUSE 100 ' pause .1 sec to hear tone HIGH PORTD.0 PAUSE 350 LOW PORTD.0 PAUSE 350 RETURN




Bookmarks