Lesson goal: Read a voltage from the Arduino (an analog value)

Previous: Buzz a wrong answer | Home | Next: Your work area temperature

This lesson will show you how to read a voltage from one of the analog inputs (A0..A5) on the Arduino.
analogread(pin)
Move the mouse over a dotted box for more information.

Now you try. Read voltages from the outside world!

Type your code here:


See your results here:

This experiment only requires the Arduino and a single wire. Insert one end of the wire into the pin labeled "A0," as shown here. Insert the free end of the wire into the 5V pin and run the code above. What do you see displayed on the screen? Next, remove the end from the 5V pin and insert it into the 0V pin and run the code again. Do you agree that the Arduino is reading in voltage? Try the 3.3V pin as well.

Dismiss.
Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

  1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

  2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

  3. Then click the "Use on iPhone" button that you'll see.