I'm doing a temperature control system. Pretty new to PIC programming. I have managed to display temperature on the LCD using an LM35 sensor and a 16 x 2 lcd with a 16F873. I want to add on a 4 x4 matrix keypad so that i can set setpoints to switch a relay and a low warning buzzer I have no idea how to program for the above mentioned add-ons. Please could someone help me. below is my code which will obviously need additions and a scematic of my circuit is attached . Please could somebody help me with this!!
' Define LCD registers and bits
Define LCD_DREG PORTB
Define LCD_DBIT 0
Define LCD_RSREG PORTB
Define LCD_RSBIT 5
Define LCD_EREG PORTB
Define LCD_EBIT 4
dEFINE LCD_BITS 4
DEFINE LCD_LINES 2
adval var word ' Create adval to store result
temp var word ' Create temp to store result
temp1 var word ' Create temp1 to store result
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %10000010 ' Set PORTA analog and RIGHT justify result
ADCON0 = %11000001 ' Configure and turn on A/D Module
Pause 100 ' Wait 0.1 second
loop: ADCON0.2 = 1 ' Start Conversion
AGAIN: Pause 1
If ADCON0.2 = 1 Then AGAIN ' Wait for low on bit-2 of ADCON0, conversion finished
adval.highbyte = ADRESH ' Move HIGH byte of result to adval
adval.lowbyte = ADRESL ' Move LOW byte of result to adval
Lcdout $fe, 1 ' Clear screen
temp=50*adval ' Conversion to Degrees
temp=temp/100
Lcdout "TEMP = ",DEC temp,$DF,"C" ' Display the value of temp
temp1 = temp*18 ' Conversion to Fahrenheit
temp1 = temp1+320
temp1 = temp1/10
lcdout $FE,$C0, "TEMP = ",dec temp1,$DF,"F" ' Display the value of temp
Pause 1000 ' Wait 1 second
Goto loop ' Do it forever
End
Bookmarks