Project - Potentiometer Control

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.

It uses a linear potentiometer (1k to 10k) with the wiper connected to ADC

Note: The NodeMCU module used here has 3.3v analog reference voltage, which allows a full ADC working range from 0v (0) to 3.3v (1023).

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------------







Comentarios