Analog Read Serial

Analog Read Serial © GPL3+

This example demonstrates how to read analog input from a potentiometer.

  • 1,441 views
  • 2 comments
  • 0 respects

Components and supplies

Apps and online services

About this project

The analog input is read and the result is printed in the Serial Monitor. When the shaft is turned all the way in one direction, there are 0 volts going to the pin, and the input value is 0. When the shaft is turned all the way in the opposite direction, there are 5 volts going to the pin and the input value is 1023. In between, analogRead() returns a number between 0 and 1023 that is proportional to the amount of voltage being applied to the pin.

Analog Read Serial

Code

SketchArduino
/*
  Analog Read Serial
  Reads an analog input on pin 0.
  prints the result to the Serial Monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
*/

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}

Schematics

Breadboad Diagram
Analog read serial bb ypjnozh2gd
Schematic Diagram
Analog read serial schem zypadlfagv

Comments

Similar projects you might like

Analog Clock with LED Matrix and Arduino

Project showcase by LAGSILVA

  • 22,452 views
  • 17 comments
  • 79 respects

2€ OLED I2C Analog Pin Dynamic Plotting

Project showcase by javier muñoz sáez

  • 10,212 views
  • 0 comments
  • 18 respects
Add projectSign up / Login