This acts like a typical rotary dimmer/speed controller available from everwhere. See the demo video
Optionally It can use an LED as a brightness/speed indicator.
Many other ESP8266 devices use a 1v analog reference voltage, giving only a 1v ADC working range, 0v (0) to 1v (1023).
If your device only has a 1v working voltage and you connect your pot to 3.3v it will only have a working range of one third its travel.The solution is to connect the wiper to a 1v reference voltage, eg: from an appropriate potential divider (perhaps even another pot).
Basic:
'Potentiometer Dimmer/Speed Controller - Electroguard - developed on Annex 1,41 beta 3
dimmer.setup 4,5,0,1 'configure dimmer module, 4 and 13 = zero crossing, 5 = pwm dimmer.limits 0, 9500 'actual min/max delay in triac firing value=0 'initial master dial startup value option.pwmfreq 100 'reduce pwm frequency to reduce cpu load ledpin=15 'optional pwm led power indicator pwm(ledpin)=value timer0 100, readADC wait readADC: value=int((adc/1024)*100) dimmer.brightness value pwm(ledpin)=value*10 return end '-----------end------------ |