Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By Zim
#74791 A timer that also shows how to adjust text box size....

Code: Select all'ESPbasic V 3.69
'Variables can be tweaked for precision times if needed
memclear
cls
io(po,4,0)           'choose your output pin
wprint "<left>"
button "10 sec", [10sec]
wprint "<br>"
button "20 min", [20min]
wprint "<br>"
button "8 hour", [8hour]
wprint "<br>"
textbox time
cssid htmlid(), "text-align:center;display:block;width:100px;height:30px;font-size:14;font-weight:bold"
wprint "<br><br>"
button "exit !!", [exit]
wprint "</left>"
wait

[10sec]
unit = " seconds"
time1 = 10
time2 = 10
dlay = 1000
fvar = 10
minus = 1
goto [time]
wait

[20min]
unit = " min"
time1 = 20
time2 = 20
dlay = 1000
fvar = 1200
minus = .017
goto [time]
wait

[8hour]
unit = " hours"
time1 = 8
time2 = 8
dlay = 1000
fvar = 28800
minus = 0.0003
goto [time]
wait

[time]
io(po,4,1)
For i = 1 to fvar
time = time2 & unit
delay dlay
time1 = time1 - minus
time2 = time1
Next i
goto [done]
[done]
io(po,4,0)
time = off
wait
[exit]
io(po,4,0)
time = off
end