0% found this document useful (0 votes)
31 views19 pages

Analog I/O: Arduino Lab 5

This document discusses analog input and output using an Arduino board. It explains that the analogRead() function reads the value from an analog pin and maps it to an integer between 0 and 1023. A potentiometer, which acts as a variable resistor, can be used to provide an analog input that can be read by the Arduino. The map() function can then remap this analog input range to control an output device like an LED. An example project uses a potentiometer to control the brightness of an LED. Sensors are also discussed as devices that detect physical properties and convert them to electrical signals that can be read by a microcontroller. Specifically, a temperature sensor and code to read temperature values from
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views19 pages

Analog I/O: Arduino Lab 5

This document discusses analog input and output using an Arduino board. It explains that the analogRead() function reads the value from an analog pin and maps it to an integer between 0 and 1023. A potentiometer, which acts as a variable resistor, can be used to provide an analog input that can be read by the Arduino. The map() function can then remap this analog input range to control an output device like an LED. An example project uses a potentiometer to control the brightness of an LED. Sensors are also discussed as devices that detect physical properties and convert them to electrical signals that can be read by a microcontroller. Specifically, a temperature sensor and code to read temperature values from
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Arduino

LAB 5

Analog I/O

Didam Ahmed

1
Analog Read

 analogRead()

 Reads the value from the specified analog pin. 

 Arduino Uno uses 10-bit analog to digital converter.

 This means that it will map input voltages between 0 and 5 volts into integer
values between 0 and 1023.

 Syntax
 analogRead(pin)
potentiometer

 A potentiometer is a simple knob that provides a variable resistance, which we can


read into the Arduino board as an analog value.
potentiometer

 Variable resistors, also known as potentiometers, can generally be adjusted


from 0 Ω up to their rated value
 Variable resistors have three pin connections: one in the center pin and one
on each side.
 As the shaft of a variable resistor turns, it increases he resistance between
one side and the center and decreases the resistance between the center and
the opposite side.
Vout =  {R2/(R1+R2)} x V; where V= supply voltage.

ExampleA resistor, R1 of 150Ω is connected in series with a 50 Ω resistor, R2 acrosss a 10 Volt
supply ohm resistor as shown . Calculate the total series resistance, the current flowing
through the series circuit and the voltage drop across the 50 ohm resistor.
potentiometer

int analogPin = 0;
int val=0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val=analogRead(analogPin);
Serial.println(val);
}
Map Function

 map()
 Mathematical Function
 Re-maps a number from one range to another.

 That is, a value of fromLow would get mapped to toLow,


 a value of fromHigh to toHigh,

 values in-between to values in-between, etc.


Project

 Using Potentiometer to control brightness of a LED

 Hardware Required

 Arduino Board
 Potentiometer
 Red LED
 220 ohm resistor
Circuit
Program
What are Sensors?

Collect information about the world


 Sensor - an electrical/mechanical/chemical device that maps
an environmental attribute to a quantitative measurement

 A sensor acquires a physical parameter and converts it into a


signal suitable for processing (e.g. optical, electrical,
mechanical)

 A device which provides a usable output in response to a


specified measurand
Need for Sensors

 Sensors are omnipresent. They are embedded in our


bodies, automobiles, airplanes, cellular telephones,
radios, chemical plants, industrial plants and
countless other applications.

 Without the use of sensors, there would be no


automation !!
Why do robots need sensors?
Will I hit anything?

obstacle detection
Sensing for specific tasks

Where is the cropline?

Autonomous
harvesting
Types of Sensors
 Active
Send signal into environment and measure interaction of signal with environment
e.g. radar, sonar
 Passive
record signals already present in environment
e.g. thermostat
Thermometer

 Temperature can be represented by an analog signal.


 We can measure temperature using the LM35 voltage output temperature sensor
made by Analog Devices
Project

 Arduino Uno 
 LM35 Temperature Sensor
 Some connecting wire.
 A to B cable
Circuit
Program

float temp;
int tempPin = A0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
temp = analogRead(tempPin);
temp = temp * 0.48828125;
Serial.print("TEMPRATURE;
Serial.print(temp);
Serial.print(" Degree Celsius");
Serial.println();
delay(1000);
}

You might also like