home_automated

This commit is contained in:
topicchi
2025-10-26 17:38:55 +00:00
parent 8b5e0498c2
commit f7ae8b4eb2

View File

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