Potentiometer and LED circuit with Arduino
Jump to navigation Jump to search
This example shows how to read a potentiometer using the Arduino and use its value to change the brightness of an LED.
Open the Serial Monitor window in the Arduino software to view the debugging messages output by the program.
- When the potentiometer is turned all the way down (offering minimum resistance), what voltage is read at Arduino pin A0?
- When the potentiometer is turned all the way up (offering maximum resistance), what voltage is read at Arduino pin A0?
- How much resistance must the potentiometer offer in order for the voltage at Arduino pin A0 be 2.5V?
- Why have I multiplied the potentiometer value (potVal in the code) by 0.25 in order to set the brightness of the LED (ledVal in the code)? In other words, why couldn't I just set the LED output value to be exactly the same value as the potentiometer input value?