Project - Web Slider Dimmer









Simple AC light dimmer / speed controller using a web page slider.  See the demo video
Optional title, eg: "Table Lamp".
Optional PWM LED indicator.
 
Basic:
'Mains WebSlider Dimmer - Electroguard - developed on Annex 1.41 beta 3
title$="Web Slider Dimmer"       'change to suit, or leave blank
value=0                                    'startup level
dimmer.setup 4,5,0,1                 'configure dimmer module, 4 and 13 = zero crossing,  5 = pwm
dimmer.limits 0, 9500                 'configured for 50hz
dimmer.brightness value             'set brightness to startup value
option.pwmfreq 100                    'reduce pwm frequency to reduce cpu load
ledpin=15 
                                 'optional pwm led indicator
pwm(ledpin)=value                      'set led brightness to startup value
onhtmlchange change                 'subroutine branch to action controller changes
gosub screen                             'send screen output to browser
wait

change:
pwm(ledpin)=value*10
dimmer.brightness value
pause 50
return

screen:
cls
a$=|<br><div style='display: table; margin-right: auto; margin-left: auto;font-size: 100%;'>|
a$=a$+title$+|<br>|
a$=a$+|</div>|
a$=a$+string$(5,"<br>")
a$=a$+|<div style='display: table; margin-right: auto; margin-left: auto;font-size: 80%;transform: rotate(-90deg);'>|
a$=a$+replace$(slider$(value,0,100,"slider"), "onchange", "oninput")
a$=a$+|</div><br>|
html a$
return

end
  '-----------end------------