Reading Analog Voltage using An Arduino
In this tutorial, I'm going to show you how to read analog voltage using the on board analog pins.
ITEMS REQUIRED
1 x LED
3 x Cables
1 x 1kΩ Resistor
1 x 1K Potentiometer.
1 x Arduino board (I am using An Arduino Uno).
1 x USB cable
1 x Computer with Arduino software installed (http://www.arduino.cc/en/Main/software if you haven't already got it)
1 x Breadboard
Circuit Theory:
The analog I/O on the arduino board can be used to read sensor data, compared to other micro controllers where analog converters need to be configured separately, the arduino uno has inbuilt Analog converter,This is one of the advantages of using arduino board for prototyping.The Arduino uno contains a multichannel, 10-bit analog to digital converter.It can map out input voltages between 0 and the operating voltage(5V or 3.3V) into integer values between 0 and 1023. ie this yields a resolution between readings of: 5 volts / 1024 units or, 0.0049 volts (4.9 mV) per unit.
On Arduino (UNO, Nano, Mini, Mega), it takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second
Step 1:
Connect the circuit as per the circuit diagram in figure 1
Step 2:
Open a new window in the arduino terminal and type the code.
/*
ReadAnalogVoltage
Reads an analog input on pin 0, converts it to voltage, and prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
*/
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue*(5.0/1023);
// print out the value you read:
Serial.println(voltage);
}
Upload the code to the arduino and check the output. You can use the serial monitor to view the output data.
You can buy your arduino from the below link.
Comments