Before we go ahead and use the LEDs, you can try a little experiment using just the variable resistor also known as a potentiometer (often called a 'pot' for short) and the Arduino Serial Monitor.
Connect up your breadboard as shown below:
Load the following sketch onto your Arduino.
/* Adafruit Arduino - Lesson 8. Analog Inputs */ int potPin = 0; void setup() { Serial.begin(9600); } void loop() { int reading = analogRead(potPin); Serial.println(reading); delay(500); }
Now open the Serial Monitor, and you will see a stream of numbers appearing.
Turn the knob on the variable resistor and you will see the number change between 0 and 1023.
The Serial Monitor is displaying the analog reading value from A0 using the line:
int reading = analogRead(potPin);
The voltage at A0 is being transformed into a number between 0 and 1023.