The document discusses various sensors and actuators that can be used with an Arduino board. It describes analog input pins and the analog-to-digital converter on the Arduino, which allows sensors to be read. It also discusses using a potentiometer to read analog sensor values and control an LED brightness. Pulse width modulation (PWM) is introduced for generating analog outputs with digital pins. Common sensors like a photoresistor, temperature sensor, and DHT11 humidity sensor are described. For outputs, the document discusses servo motors and controlling servo position either with code or a potentiometer. It also mentions libraries that add functionality to Arduino sketches.
3. Analog Input Pins
A/D converter
The Arduino Uno contain an onboard 6 channel
analog-to-digital (A/D) converter.
The converter has 10 bit resolution, returning integers
from 0 to 1023.
While the main function of the analog pins for most
Arduino users is to read analog sensors, the analog
pins also have all the functionality of general purpose
input/output (GPIO) pins
7. PWM (“Analog Output”)
Pulse Width Modulation, or PWM, is a technique for getting
analog results with digital means. Digital control is used to
create a square wave, a signal switched between on and
off. This on-off pattern can simulate voltages in between
the full Vcc of the board (e.g., 5 V on Uno) and off (0 Volts)
by changing the portion of the time the signal spends on
versus the time that the signal spends off. The duration of
“on time” is called the pulse width. To get varying analog
values, you change, or modulate, that pulse width. If you
repeat this on-off pattern fast enough with an LED for
example, the result is as if the signal is a steady voltage
between 0 and Vcc controlling the brightness of the LED.
8.
9.
10. Using Potentiometer to Control LED Light
analogRead (pin): Read the value of the specified
analog pin.
Return value: an integer between 0 to 1023
analogRead( ) function to read the analog input value,
and the input value range is between 0 to 1023.
Then use the analogWrite( ) function (PWM) to change
the LED light duty cycle, and the duty cycle range is 0
to 255.
Need to remap the range by using the map( ) function.
11. map(value, fromLow, fromHigh, toLow, toHigh): Map
data from one range to another
value: The data to be mapped.
fromLow: The lower limit of the current range.
formHigh: The upper limit of the current range.
toLow: The lower limit of the target range.
toHigh: The upper limit of the target range.
Return value: Remapped data
16. Uses a resistor divider to allow the high impedence
Analog input to measure the voltage.
Use analogRead() to convert the input voltage range,
0 to 5 volts, to a digital value between 0 and 1023 (10
bit resolution).
19. int val;
int tempPin = A0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val = analogRead(tempPin);
float mv = (val/1024.0)*5000;
float cel = mv/10;
Serial.print(“TEMPRATURE = ”);
Serial.print(cel);
Serial.print(“*C”);
Serial.println();
delay(1000);
}
20. DHT11 Sensor
The DHT11 is a basic, ultra low-cost digital
temperature and humidity sensor. It uses a capacitive
humidity sensor and a thermistor to measure the
surrounding air and spits out a digital signal on the
data pin (no analog input pins needed).
Its fairly simple to use, but requires careful timing to
grab data. The only real downside of this sensor is you
can only get new data from it once every 2 seconds,
the sensor readings can be up to 2 seconds old.
21. DHT11 Sensor
Technical Details
Low cost
3 to 5V power and I/O
2.5mA max current use during conversion (while
requesting data)
Good for 20-80% humidity readings with 5%
accuracy
Good for 0-50°C temperature readings ±2°C accuracy
No more than 1 Hz sampling rate (once every second)
Body size 15.5mm x 12mm x 5.5mm
22. How DHT11 Works
The DHT11 detects water vapor by measuring the
electrical resistance between two electrodes. The
humidity sensing component is a moisture holding
substrate with electrodes applied to the surface. When
water vapor is absorbed by the substrate, ions are
released by the substrate which increases the
conductivity between the electrodes. The change in
resistance between the two electrodes is proportional to
the relative humidity. Higher relative humidity decreases
the resistance between the electrodes, while lower
relative humidity increases the resistance between the
electrodes.
26. Libraries
The Arduino environment can be extended through
the use of libraries, just like most programming
platforms.
Libraries provide extra functionality for use in
sketches, e.g. working with hardware or manipulating
data.
To use a library in a sketch, select it from Sketch >
Import Library.
A number of libraries come installed with the IDE, but
you can also download or create your own.
27. Standard Libraries
EEPROM - reading and writing to "permanent" storage
Ethernet - for connecting to the internet using the Arduino
Ethernet Shield, Arduino Ethernet Shield 2 and Arduino
Leonardo ETH
Firmata - for communicating with applications on the
computer using a standard serial protocol.
GSM - for connecting to a GSM/GRPS network with the
GSM shield.
LiquidCrystal - for controlling liquid crystal displays (LCDs)
SD - for reading and writing SD cards
Servo - for controlling servo motors
28. SPI - for communicating with devices using the Serial Peripheral
Interface (SPI) Bus
SoftwareSerial - for serial communication on any digital pins.
Version 1.0 and later of Arduino incorporate Mikal Hart's
NewSoftSerial library as SoftwareSerial.
Stepper - for controlling stepper motors
TFT - for drawing text , images, and shapes on the Arduino TFT
screen
WiFi - for connecting to the internet using the Arduino WiFi
shield
Wire - Two Wire Interface (TWI/I2C) for sending and receiving
data over a net of devices or sensors.
32. Servo Motor
A servo motor (or servo) is a motor that allows for
precise control of angular position. Unlike DC motors
where we can only control the rotational speed and
the direction of rotation, a servo motor allows us to
control the angle of rotation. Tower Pro SG90 Micro
Servo is a tiny and lightweight servo commonly used
in small robots. SG90 servo can rotate approximately
180 degrees. The operating speed is about 0.1s for a
60-degree rotation.