Professional Documents
Culture Documents
LAB 5
Analog I/O
Didam Ahmed
1
Analog Read
analogRead()
This means that it will map input voltages between 0 and 5 volts into integer
values between 0 and 1023.
Syntax
analogRead(pin)
potentiometer
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.
Hardware Required
Arduino Board
Potentiometer
Red LED
220 ohm resistor
Circuit
Program
What are Sensors?
obstacle detection
Sensing for specific tasks
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
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);
}