You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thomas E. Horner edited this page Mar 12, 2019
·
12 revisions
Specification
What
Comments
Identifier
LINEAR_POT
Interface
ADC
Provides
val
Potentiometer % value, from 0.0 to 1. 0 is 0%, 1.0 is 100%, 0.5 is 50%.
Properties
none
Callbacks?
no
Code
In this example a potentiometer is used to control the brightness of a led (using PWM).
-- Attach a led at GPIO32led=pwm.attach(pio.GPIO32, 1000, 0)
led:start()
-- Attach a potentiometer connected to an external ADC (ADS1115) / cannel 0s=sensor.attach("LINEAR_POT", adc.ADS1115, 0)
-- Read potentiometer value every 10 msecsthread.start(function()
whiletruedotmr.delayms(10)
led:setfreq(1000)
led:setduty(s:read("val"))
endend)