Skip to content

About

Curated hardware project: Analog Input

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Analog Input

To read an analog signal through an Arduino, Analog to Digital Conversion or ADC is required. The arduino has 10bit ADC which means it scales an analog signal in a range of 0-1023.

An analog input signal is taken through the Analog input pins A0-A5 of the arduino. In this example an analog input is taken and it is displayed on the LED where you can observe by the delay in glowing the LED.

Have Fun !

Components Required

  1. LED
  2. Resistor 220
  3. Potentiometer
  4. Jumper Wires
  5. Arduino UNO

CODE

int sensorPin = A2;    // select the input pin for the potentiometer
int ledPin = 3;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);
  // stop the program for <sensorValue> milliseconds:
  delay(sensorValue);
  // turn the ledPin off:
  digitalWrite(ledPin, LOW);
  // stop the program for for <sensorValue> milliseconds:
  delay(sensorValue);
}

About

Curated hardware project: Analog Input

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors