home_automated
This commit is contained in:
@@ -40,39 +40,49 @@ dir ledG out
|
||||
dir ledR out
|
||||
dir ledB out
|
||||
|
||||
dim t1 as byte
|
||||
dim t2 as byte
|
||||
dim t3 as byte
|
||||
dim temp as word
|
||||
|
||||
'Startup routine
|
||||
Startup:
|
||||
SET ledG OFF
|
||||
SET ledR OFF
|
||||
set ledB OFF
|
||||
t1=100
|
||||
t2=100
|
||||
t3=100
|
||||
|
||||
'Main routine
|
||||
Main:
|
||||
Do
|
||||
'Read temperature
|
||||
'temp=ReadAD(ADC2)
|
||||
temp=ReadAD(PTH)
|
||||
t1=t2
|
||||
t2=t3
|
||||
t3=ReadAD(PTH)
|
||||
temp=average(t3, t2)
|
||||
|
||||
if temp < S1 then
|
||||
set ledB ON
|
||||
SET ledG OFF
|
||||
SET ledR OFF
|
||||
end if
|
||||
if (temp > S1) and (temp <S2) then
|
||||
if (temp >= S1) and (temp <S2) then
|
||||
set ledB OFF
|
||||
SET ledG ON
|
||||
SET ledR OFF
|
||||
end if
|
||||
if (temp > S2) and (temp <S3) then
|
||||
if (temp >= S2) and (temp <S3) then
|
||||
set ledB OFF
|
||||
SET ledG ON
|
||||
SET ledR ON
|
||||
end if
|
||||
if temp > S3 then
|
||||
if temp >= S3 then
|
||||
set ledB OFF
|
||||
SET ledG OFF
|
||||
SET ledR ON
|
||||
end if
|
||||
|
||||
Wait 100 ms
|
||||
Wait 1000 ms
|
||||
'Jump back to the start of the program
|
||||
goto Main
|
||||
Loop
|
||||
|
||||
Reference in New Issue
Block a user