I know this seems like a simple question, but I want to make sure my code is in the right ball park. The section of code should add 1 or minus 1 to a setpoint that another part of code will interpret and output to and lcd and turn on a red led or a green led
ADCON1 = 7 ' Set PORTD and PORTE to digital
Setpoint Var word
Temp_Down Var PortB.3 'Temp down button input port
Temp_Up VAR PortB.2 'Temp up button input port
R_LED VAR PortB.0 ' Red LED output
G_LED VAR PortB.1 ' Green LED output
DQ VAR PortC.0 ' One-wire Data-Pin "DQ" on PortC.0
Busy VAR BIT ' Busy Status-Bit
Sign VAR BYTE ' +/- sign for temp display
Dummy VAR BYTE ' Dummy for Div32
R_Temp VAR WORD ' RAW Temperature readings
TempC VAR WORD ' Temp in deg C
TempF VAR WORD ' Temp in deg F
Float VAR WORD ' Holds remainder for + temp C display
Cold_Bit VAR R_Temp.Bit11' Sign-Bit for +/- Temp. 1 = Below 0 deg C
Real_Cold CON 1 ' Define Real_Cold = 1
DS18B20_9bit CON %00011111 ' 93.75ms, 0.5°C
DS18B20_10bit CON %00111111 ' 187.5ms, 0.25°C <-- My favorite
DS18B20_11bit CON %01011111 ' 375ms, 0.125°C
DS18B20_12bit CON %01111111 ' 750ms, 0.0625°C (default)
OPTION_REG = $7f
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_10bit] 'Skip ROM search and write 10bit resolution to scratch pad
Pause 500
LCDOut $FE 'Clear LCD
Setpoint = 22
Start_Convert:
OWOUT DQ, 1, [$CC, $44] ' Skip ROM search & do temp conversion
PortB = 0
If Temp_Up = 0 Then
Setpoint = Setpoint + 1
Endif
If Temp_Down = 0 Then
Setpoint = Setpoint - 1
Endif
lcdout $fe, 1, "Setpoint = ", #Setpoint
If TempC < Setpoint Then
high R_LED ' Turn on Red LED and turn off Green LED
low G_LED
Else
High G_LED ' Turn on Green LED and turn off Red LED
low R_LED
EndIf