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.