; Lesson-004-DS18B20Temperature.bas #picaxe 20M2 ; Define the µProcessor IC Type ; Declare Constants & Variables symbol RLED = B.7 symbol GLED = B.6 symbol BLED = B.5 symbol temp = B.0 symbol i = b0 ; BEGIN Main Body * * * * * * * * * * * * * * * * * * * * * * * * do readtemp temp, b1 ; Read the DS18B20 temperature debug ; Display the temperature reading on the if b1 >= 25 then gosub red ; it's hot outside if b1 < 23 then gosub blue ; it's cold outside if b1 >= 23 and b1 < 25 then gosub green ; it's nice outside pause 1000 ; wait 1 second loop ; END Main Body * * * * * * * * * * * * * * * * * * * * * * * ** end ; BEGIN Subroutines * * * * * * * * * * * * * * * * * * * * * * * red: low RLED high GLED high BLED return green: high RLED low GLED high BLED return blue: high RLED high GLED low BLED return Police: For i = 0 to 4 gosub red pause 50 gosub LEDsOFF pause 50 gosub red pause 50 gosub LEDsOFF pause 100 gosub blue pause 50 gosub LEDsOFF pause 50 gosub blue pause 50 gosub LEDsOFF pause 100 next i return LEDsOFF: high RLED ; switch RED OFF high GLED ; switch Green OFF HIGH BLED ; switch Blue OFF return ; END Subroutines * * * * * * * * * * * * * * * * * * * * * * ** end