Potentiometer and LED circuit with Arduino

From Knowledge Kitchen
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.


The circuit

Potentiometer and LED circuit with Arduino


The code

potentiometer_and_led_with_arduino_code


Questions

  1. When the potentiometer is turned all the way down (offering minimum resistance), what voltage is read at Arduino pin A0?
  2. When the potentiometer is turned all the way up (offering maximum resistance), what voltage is read at Arduino pin A0?
  3. How much resistance must the potentiometer offer in order for the voltage at Arduino pin A0 be 2.5V?
  4. 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?


What links here