Project tutorial
Analog Input Channels

Analog Input Channels © GPL3+

Max out the analog input channels with six 10kΩ potentiometers.

  • 344 views
  • 0 comments
  • 0 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

Introduction

If you followed along with our previous projects, you should have a good understanding of how to use the digital I/O for control, communication, and reading inputs on the Arduino Uno Rev3 (Uno). In this project, we’re going to show you how to use the analog input channels. The number of channels varies per board, but the Uno has six channels. You will learn how to read each channel and display the value into an organized table on the Serial Monitor, as shown below.

Potentiometer

The potentiometer is a component that consists of 3 pins and allows you to quickly vary the internal resistance. By varying the resistance, the output voltage is changed between 0V and the maximum voltage that the potentiometer is tied to. For example, if pin 1 is tied to +5Vdc and pin 3 is tied to 0V (GND), the output voltage on pin 2 will vary between 0V and +5V. The potentiometer acts as a voltage divider circuit, as shown below.

Analog Input

On each analog input channel, there is a 10-bit analog-to-digital (ADC) converter. Being that it has a 10-bit resolution, we can acquire samples ranging from 0 to 1023 (2^10 – 1). If your voltage range is from 0-5V, 0V will be mapped to 0 and 5V will be mapped to 1023. To figure out what each voltage between 0V and 5V will get mapped to, we can use the ratio below.

Let’s say we acquire a voltage sample of 1V. We know n, the max input voltage, and the voltage sample, so we can solve for the ADC value, as shown below. Since the solution is not a whole number, the ADC will round down to the nearest whole number which is 204.

Wiring the Circuit

Place six 10kΩ potentiometers onto the breadboard. Wire pin 3 of each potentiometer to the positive voltage rail and pin 1 to the negative rail of the breadboard. Insert a male jumper into each node that pin 2 of the potentiometers are connected to. Then, wire the other end of each jumper to Analog Inputs 0-5. A circuit schematic is shown below.

FuelCan Wiring

If you haven’t mounted the Uno onto the prototyping area of the FuelCan, go ahead and do that. I placed the breadboard in the bottom storage compartment to limit the length of the jumper wires. We need to supply +5V and GND to the power and ground rails on the breadboard. Use the provided banana jack to test-lead clip cables to do so. You will need two male header pins to mount the test-lead clips on the breadboard side. Plug the Type A side of the USB cable into USB1 receptacle and the Type B side into the Uno’s receptacle. Power up the FuelCan with the AC-DC power adapter.

Software

Once the wiring is complete and the FuelCan is powered up, we can now load the sketch onto the Uno. The sketch is below. It sets up the serial terminal between the Uno and the host. The analog values are read from each analog input and the values are sent to the host to display them on the Serial Monitor. Rotate each potentiometer clockwise and counterclockwise to watch the values change from 0 to 1023.

Code

Read Six Analog ChannelsArduino
//Read the six 10-bit analog values from each potentiometer
//and display them in an organized table on the Serial Monitor

//variable declarations
int A0value = 0;
int A1value = 0;
int A2value = 0;
int A3value = 0;
int A4value = 0;
int A5value = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.print("Readings from analog channels 0-5");
  Serial.print("\n\n");
  Serial.print("A0\tA1\tA2\tA3\tA4\tA5\n\n");

}

void loop() {
  // put your main code here, to run repeatedly:
  A0value = analogRead(A0);
  A1value = analogRead(A1);
  A2value = analogRead(A2);
  A3value = analogRead(A3);
  A4value = analogRead(A4);
  A5value = analogRead(A5);
  
  Serial.print(A0value);
  Serial.print('\t');
  Serial.print(A1value);
  Serial.print('\t');
  Serial.print(A2value);
  Serial.print('\t');
  Serial.print(A3value);
  Serial.print('\t');
  Serial.print(A4value);
  Serial.print('\t');
  Serial.print(A5value);
  Serial.print('\n');
  delay(3000);
  
}

Schematics

Circuit Schematic
Circuit schematic 2 qqqr4wo3ez

Comments

Similar projects you might like

An Isolated Analog Input for Arduino

Project tutorial by Giovanni Carrera

  • 5,824 views
  • 10 comments
  • 7 respects

Arduino + LabVIEW p.3 - analog IO

Project tutorial by Sebastian Peryt

  • 2,359 views
  • 0 comments
  • 13 respects

Pressure Airflow Measure Device with Analog Sensor

Project tutorial by ItMightBeWorse

  • 4,698 views
  • 2 comments
  • 11 respects

6 Channel Analog Temperature Logger

Project in progress by Dooni

  • 1,947 views
  • 1 comment
  • 8 respects

Arduino Analog Panel Meter Clock

Project tutorial by Mirko Pavleski

  • 6,421 views
  • 8 comments
  • 54 respects
Add projectSign up / Login