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() 

void loop() 
  int reading  = analogRead(potPin);

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.

This guide was first published on Dec 10, 2012. It was last updated on Dec 10, 2012.

This page (An Experiment) was last updated on Oct 12, 2012.

Text editor powered by tinymce.