stickers_logo_text

Arduino Tutorial 07: Analog Inputs

Hello!!!!!!!!!  & welcome back guys, in this tutorial of arduino. In this tutorial, we are going to talk about how to read analog inputs using arduino uno board and display analog  input value on serial monitor.

Let’s get started.

Requirement

  • 1 x Arduino Uno R3 Board
  • 1 x Laptop or pc
  • 1 x Bread board full size
  • 1 x POT(Variable Resister)
  • 1 x USB cable
  • Jumper wires

Connection Diagram

tutorial_bb

 

Source Code 01

>> This code is responsible to read analog readings of POT on serial monitor.

int analog=A1;
int analogValue = 0;
void setup() {
 // put your setup code here, to run once:
 Serial.begin(9600);
}
void loop() {
 // put your main code here, to run repeatedly:
 analogValue = analogRead(analog);
 Serial.println(analogValue);
 delay(200);
 
}
result01

Source Code 02

>> This code is responsible to calculate and display resistance value on serial monitor.

Note: Connection are same as above.

int analog=A1;
int analogValue=0;
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:
 analogValue = analogRead(A0);
 // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
 float resistor = analogValue * (5.0 / 1023.0);
 // print out the value you read:
 Serial.print("Resistance: ");
 Serial.println(resistor);
 delay(100);
}
result02

 

Download

Analog Read

Resistance calculation

!!!!!!!!!!!!!!!!!!!!Congratulations Enjoy!!!!!!!!!!!!!!!!!! 

Hope you guys like our tutorial series. We will see you in the next tutorial with new programming and electronics concepts.

comments powered by Disqus

how can we help you?

Please leave your contact details, Our customer relationship manager will assist you.

get in contact
Be the Campus Ambassador of ELAN IIT Hyderabad!