We will control the brightness of a led using a potentiometer.
Hardware: An Arduino, a led, a potentiometer.
Attach led to arduino port D9. attach potentiometer to A0.
now, arduino can read value from potentiometer using analogRead(), and control brightness using analogWrite().
But you need to remember, in arduino, the range of analog Input is [0 – 1023], the range of digital anlogWrite is [0 – 255]. A simple way to map potentiometer value to brightness value is divide analog value by 4. another method is using map module.
6,296 total views, 7 views today