#picaxe 18m2 'version D.A AXE132 8Bit marks
SYMBOL E = C.6
SYMBOL RS = C.7
SYMBOL DS18B20 = C.2 ' 1431 C4 +662AB
SYMBOL Switches = C.2 '
SYMBOL senddata = pinsb
SYMBOL index = b0
SYMbol PushButton = b1
SYMBOL Temperature = W1 SYMBOL TempMsb = b3 SYMBOL TempLsb = b2
SYMBOL Counter = b4
SYMBOL Sign = b5
SYMBOL D0 = b10
SYMBOL D1 = b11
SYMBOL D2 = b12
SYMBOL D3 = b13
SYMBOL D4 = b14
SYMBOL Lo = W8
SYMBOL Hi = W9
SETFREQ M32
dirsB = %11111111
dirsC = %11001011
EEPROM 10,(6 ,9 ,9 ,6 ,0 ,0 ,0 ,0) ' load custom character (o) =0 degrees symbol
EEPROM 18,(0 ,17,27,21,17,17,17,0) ' load custom character (M) =1
Initialise:
FOR index = 0 to 7
LOOKUP index, ($38,$38,$38,$08,$01,$02,$06,$0C),senddata : PULSOUT E,1 ' Initialise LCD/OLED
'(8bit/2line/5x8)*3(Display Off)(Clear Display)(Return Home)(Entry Mode Set)(Display On)
NEXT index : PAUSE 10
LoadCustomCharactersFromEEPROM:
LOW RS : senddata = $40 : pinsB = senddata : PULSOUT E,1 : HIGH RS ' Load Characters to LCD
FOR index =10 TO 25
READ index, senddata : pinsB = senddata : PULSOUT E,1 ' sending characters to LCD
NEXT index
Default: d0="C" ' "C"for Celsius "F"for Fahrenheit
ResetMinMax: Hi = 0 : Lo = 2927
Main:
ReadADC Switches,pushbutton : LET pushbutton=pushbutton/242+1//2 '(4.7k/47k()230)
let adcsetup = %1000000000 ' reenable digital pin for DS18B20
IF pushbutton = 0 THEN
IF counter >0 AND counter <6 Then
If d0 = "C" then let d0 = "F" : goto ResetCounter: endif
If d0 = "F" then let d0 = "C" : endif
Endif
ResetCounter: counter = 0
ENDIF
DisplayTemperatureMinMax:
ReadTEMP12 DS18B20,Temperature
Temperature = Temperature + 880
IF Temperature > Hi THEN LET Hi = Temperature: ENDIF
IF Temperature < Lo THEN LET Lo = Temperature: ENDIF
IF d0 ="C" then : Temperature = Temperature * 5 / 8 -550 :endif 'Celsius
IF d0 ="F" then : Temperature = Temperature * 9 / 8 -670 :endif 'Fahrenheit
Sign = " " : IF TempMsb > 127 THEN : Temperature = -Temperature : Sign = "-" : ENDIF
BinTOASCII Temperature,D4,D4,D3,D2,D1
IF D4 = "0" THEN : D4 = Sign ' leading zero blanking
IF D3 = "0" THEN : D3 = Sign : D4 = " " : ENDIF ' leading zero blanking
ENDIF
LOW RS : senddata = 192 : PULSOUT E,1 ' commandmode (128)Line 1 (192)Line 2
HIGH RS ' charactermode
FOR index = 0 TO 8
LOOKUP index,(D4,D3,D2,".",D1,0,D0," ",1),senddata : PULSOUT E,1
NEXT index
IF pushbutton = 1 THEN : INC counter : ENDIF
IF counter >5 THEN
FOR index = 0 TO 6
LOOKUP index,(" reset"),senddata : PULSOUT E,1
NEXT index
GOTO ResetMinMax
ENDIF
sign=Time//2 ' change state every 15 secs time extended due to using Readtemp12
if sign=0 then: Temperature = Lo : senddata = "i" : PULSOUT E,1 : senddata = "n" :endif
if sign=1 then: Temperature = Hi : senddata = "a" : PULSOUT E,1 : senddata = "x" :endif: PULSOUT E,1
IF d0 ="C" then : Temperature = Temperature * 5 / 8 -550 :endif 'Celsius
IF d0 ="F" then : Temperature = Temperature * 9 / 8 -670 :endif 'Fahrenheit
Sign = " " : IF TempMsb > 127 THEN : Temperature = -Temperature : Sign = "-" : ENDIF
BinTOASCII Temperature,D4,D4,D3,D2,D1
IF D4 = "0" THEN : D4 = Sign ' leading zero blanking
IF D3 = "0" THEN : D3 = Sign : D4 = " " : ENDIF ' leading zero blanking
ENDIF
FOR index = 0 TO 4
LOOKUP index,(D4,D3,D2,".",D1),senddata : PULSOUT E,1
NEXT index
GOTO Main