ANALOG INPUT analysis of ARDUINO UNO using POTENTIOMETER!

There are six analog input pins in arduino uno namely A0- A5. In arduino mega we can find sixteen analog pins and eight analog pins in arduino nano. Analog pins are used when we want to read or write variable voltage from 0V to 5V. All the arduino boards consists of 10bit ADC. I.e 0V will be read as zero and 5V will be read as 1023 by the microcontroller arduino board. All the voltage ranges between 0 and 5 will lie between 0 and 1023.

Potentiometer is used as a voltage divider such that when the knob of the potentiometer is rotated, variable DC voltage can be read by the microcontroller in the Arduino board through any of the analog pins.

 

HARDWARE REQUIRED :-

  • Arduino UNO
  • Potentiometer

breadboard

Reading the position of the Potentiometer:
This project teaches you reading the analog input from the A0 pin and also realizing the in the serial monitor. The central pin of the potentiometer is connected to the analog pin A0 and the both other pins are connected to th +5V power supply and ground respectively. The voltage value to the analog pin A0 is varied as the potentiometer is either rotated clockwise or anti-clockwise. This is how the potentiometer is acting as a “variable voltage sensor”.

CODE AND THE EXPLANATION :-

int sensorPin = A0;
int sensorValue = 0;
void setup()
{
Serial.begin(9600);

}

void loop()
{
sensorValue = analogRead(sensorPin);
Serial.printIn(sensorValue);
delay(100);
}

In the program, analog pin ‘A0’ is assigned to variable sensorPin and we also take another integer variable sensorValue to get the analog value from the analog pin A0.
Initially the sensorValue is set to zero. In setup routine we initialize serial communication to 9600 bits per second. This opens serial communication between arduino board and the laptop and allows us to view data sent from the microcontroller in the arduino board through the serial monitor.

The value obtained bt analodRead( at sensor pin A0 is placed in variable “sensorValue” and is simultaneously printed to the serial monitr. After this the program passes for 100 milliseconds and the loop routine runs over and over again.

We will get a reading of 0 when the potentiometer is at the minimum position and 1023 when the potentiometer is at the maximum postition.

Snapchat-411014557.jpg

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s