-->
Page 1 of 2

Simple web-controlled output

PostPosted: Sun Jan 03, 2016 5:11 pm
by luc VdV
' define outputpin
let OutputPinNo = 0
' define initial state. Led is connected to+V so 1 means led=off
let OutputPinState = 1
' update the output and build the web-page
gosub [Update]
wait
[ImgClicked]
if OutputPinState = 0 then goto [SwitchTo1]
OutputPinState = 0
goto [ImgClickedExit]
[SwitchTo1]
OutputPinState = 1
[ImgClickedExit]
gosub [Update]
wait
[Update]
po OutputPinNo OutputPinState
cls
wprint "Created with ESP8266 Basic V1.71<br>"
if OutputPinState = 0 then goto [OutputIsLow]
imagebutton lamp_off.png [ImgClicked]
goto [UpdateExit]
[OutputIsLow]
imagebutton lamp_on.png [ImgClicked]
[UpdateExit]
button "exit" [Exit]
return
[Exit]
end


That's all it takes. Don't forget to upload 2 pictures. :)
Connect a SMD-relay instead of a led to drive large loads.

Re: Simple web-controlled output

PostPosted: Tue Jan 05, 2016 12:25 am
by forlotto
Code: Select all' define outputpin
let OutputPinNo = 0
' define initial state. Led is connected to+V so 1 means led=off
let OutputPinState = 1
' update the output and build the web-page
gosub [Update]
wait
[ImgClicked]
if OutputPinState = 0 then goto [SwitchTo1]
OutputPinState = 0
goto [ImgClickedExit]
[SwitchTo1]
OutputPinState = 1
[ImgClickedExit]
gosub [Update]
wait
[Update]
po OutputPinNo OutputPinState
cls
wprint "Created with ESP8266 Basic V1.71<br>"
if OutputPinState = 0 then goto [OutputIsLow]
imagebutton lamp_off.png [ImgClicked]
goto [UpdateExit]
[OutputIsLow]
imagebutton lamp_on.png [ImgClicked]
[UpdateExit]
button "exit" [Exit]
return
[Exit]
end


Well done picture buttons I like it ;)

Have you tested clicking this on and off say 30 times as quickly as possible without stopping to see if the ESP8266 hangs up and resets?

Kind of curious to see what happens thanks!

Re: Simple web-controlled output

PostPosted: Tue Jan 05, 2016 6:34 pm
by Mmiscool
This is a nifty example. Would be nice to get some of these examples up on http://www.instructables.com/

Re: Simple web-controlled output

PostPosted: Wed Jan 06, 2016 7:24 am
by luc VdV
forlotto wrote:Have you tested clicking this on and off say 30 times as quickly as possible without stopping to see if the ESP8266 hangs up and resets?
Kind of curious to see what happens thanks!


Have tested it +/-100 times as fast as I can click. Output reacts as it should. Html can't refresh fast enough but once I stop clicking, it refreshes 2 or 3 times and it shows the exact image.
No crashes or hangups noticed BUT......
it seems this is only working with google-chrome browser. Tested it also with IE explorer and firefox. They do not work.... :?
It seems (for as far as I can understand html) the image-type has no property 'value'.
to be continued ....