0% found this document useful (0 votes)
191 views45 pages

Arduino Basics for Beginners

Here are 3 Arduino projects using different sensors and actuators: 1. Robotic arm elbow control using servo motors: - Use 2 servo motors connected to Arduino to control elbow joint movement up and down. - Write code to rotate servos to specific angles to achieve up and down motion. 2. Fan speed control using temperature sensor: - Use DHT11/DHT22 temperature & humidity sensor to read room temperature. - Connect fan to PWM pin to control speed. - Write code to increase/decrease fan speed based on temperature threshold. 3. Bluetooth controlled robotic arm: - Connect HC-05/HC-06 Bluetooth module to Arduino. - Pair mobile app

Uploaded by

D4D DREDD yt
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)
191 views45 pages

Arduino Basics for Beginners

Here are 3 Arduino projects using different sensors and actuators: 1. Robotic arm elbow control using servo motors: - Use 2 servo motors connected to Arduino to control elbow joint movement up and down. - Write code to rotate servos to specific angles to achieve up and down motion. 2. Fan speed control using temperature sensor: - Use DHT11/DHT22 temperature & humidity sensor to read room temperature. - Connect fan to PWM pin to control speed. - Write code to increase/decrease fan speed based on temperature threshold. 3. Bluetooth controlled robotic arm: - Connect HC-05/HC-06 Bluetooth module to Arduino. - Pair mobile app

Uploaded by

D4D DREDD yt
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/ 45

Intro to the Arduino

Topics:
The Arduino
Digital IO
Analog IO
Serial Communication
DHT11 is used to calculate
• A) temperature
• B) Humidity
• C) distance
• D) both A and B
To rotate the servo motor to 90
degree the pulse of ____ is to be
provided
• A) 1 msec
• B) 1.5 msec
• C) 2 msec
• D) 1 microsecond
Ultrasonic Sensor (HC-SR04)
• An Ultrasonic sensor is a device that can measure the
distance to an object by using sound waves.
• It measures distance by sending out a sound wave at a
specific frequency and listening for that sound wave to
bounce back.
• By recording the elapsed time between the sound
wave being generated and the sound wave bouncing
back, it is possible to calculate the distance between
the sonar sensor and the object.
 
(1) Using IO trigger for at least 10us high level signal,
(2) The Module automatically sends eight 40 kHz and detect whether there is a pulse signal
back.
(3) IF the signal back, through high level , time of high output IO duration is the time from
sending ultrasonic to returning.
What will be the output of following program?

• void setup() • A) Pin 3 will be HIGH only when


pin 2 get HIGH input
• {int v;
• pinMode(3,OUTPUT); • B) Pin 3 will be High and LOW
• pinMode(2,INPUT); alternatively
• }
• C) error
• void loop(){
• v=digitalRead(2); • D) Pin 3 will never be LOW
• if(v==HIGH)
• {digitalWrite(3,HIGH);
• delay(1000);
• digitalWrite(3,LOW);
• }
WAP to display smiles as distance is increasing or decreasing.
PIR SENSOR
• PIR sensors allow you to sense motion, almost always used
to detect whether a human has moved in or out of the
sensors range.
• They are small, inexpensive, low-power, easy to use and
don't wear out.
• For that reason they are commonly found in appliances and
gadgets used in homes or businesses.
• It detects the IR radiation wavelength between 8 to 14
micrometers.(generated by human or animals)
• They are often referred to as PIR, "Passive Infrared",
"Pyroelectric", or "IR motion" sensors.
PIR Sensor
• PIRs are basically made of a pyroelectric sensor (which you can
see above as the round cover with a rectangular crystal in the
center), which can detect levels of infrared radiation.
• Everything emits some low level radiation, and the hotter
something is, the more radiation is emitted. 
Working
• The PIR sensor itself has two slots in it, each slot is made of a
special material that is sensitive to IR. 
• When the sensor is idle, both slots detect the same amount of IR,
the ambient amount radiated from the room or walls or outdoors.

• When a warm body like a human or animal passes by, it first


intercepts one half of the PIR sensor, which causes a positive
differential change between the two halves.
• When the warm body leaves the sensing area, the reverse happens,
whereby the sensor generates a negative differential change.
• These change pulses are what is detected.
Circuit Diagram
• Pin1 -VCC
• Pin 2- Output of PIR sensor connected to 2
pin of arduino
• Pin 3-Ground
• Problem: You want to detect when people are moving near a
sensor.
• Solution: Use a motion sensor such as a Passive Infrared (PIR)
sensor to change values on a digital pin when someone moves
nearby.

• Check the data sheet for your sensor to identify the correct pins.
• The Parallax PIR Sensor (555-28027) has pins marked “OUT”, “-”,
and “+” (for Output, Gnd, and +5V).
• The SparkFun PIR Motion Sensor (SEN-08630) is marked with
“Alarm”, “GND”, and “DC” (for O/P, Gnd, and +5V).
/* PIR sketch: a Passive Infrared motion sensor connected to pin 2 lights the LED
on pin 13
*/
const int ledPin = 13;
const int inputPin = 2;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(inputPin, INPUT);
}
void loop()
{
int val = digitalRead(inputPin);
if (val == HIGH)
{
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
}
}
int ledPin = 13;
int inputPin = 2;
int pirState = LOW;
int val = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(inputPin, INPUT);
Serial.begin(9600);
}
DC Motor
• Working principle of a DC motor --A motor is an electrical
machine which converts electrical energy into mechanical energy.
• The principle of working of a DC motor is that "whenever a
current carrying conductor is placed in a magnetic field, it
experiences a mechanical force".
• A DC motor (Direct Current motor) is the most common type of
motor. DC motors normally have just two leads, one positive and
one negative.
• If you connect these two leads directly to a battery, the motor will
rotate. If you switch the leads, the motor will rotate in the
opposite direction.
• To control the direction of the spin of DC motor, without
changing the way that the leads are connected, you can
use a circuit called an H-Bridge.
• An H bridge is an electronic circuit that can drive the
motor in both directions.
• H-bridges are used in many different applications, one of
the most common being to control motors in robots.
• It is called an H-bridge because it uses four transistors
connected in such a way that the schematic diagram
looks like an "H." 
Controlling Speed of DC Motor
• We will connect the Arduino to IN1 (pin 5), IN2
(pin 7), and Enable1 (pin 6) of the L293d IC.
Pins 5 and 7 are digital, i.e. ON or OFF inputs,
while pin 6 needs a pulse-width modulated
(PWM) signal to control the motor speed.
Program
Servo Motor
• A servo motor allows a precise control of the angular position,
velocity, and acceleration. It’s like you’re at the steering wheel of
your car.
• You control precisely the speed of the car and the direction.

• These servos are essential parts if we need to control the position


of objects, rotate sensors, move arms and legs, drive wheels and
tracks, and more.
• Inside the micro servo, you will find the pieces like they are
showing in the above image.
• The top cover hosts the plastic gears while the middle cover
hosts a DC motor, a controller, and the potentiometer.
• The servo motor has three leads, with one more than a DC
motor.

• Each lead has a color code.

• So you have to connect the brown wire from the micro servo
to the GND pin on the Arduino.
• Connect the red wire from the servo to the +5V on the
Arduino.
• And finally, connect the orange wire from the SG90 servo to a
digital pin (pin 9) on the Arduino.
Timing diagram
Program
#include <Servo.h> void loop()
Servo myservo; {
int potpin = A0; val = analogRead(potpin);
int val; val = map(val, 0, 1023, 0, 180);
void setup() myservo.write(val);
{
myservo.attach(9); delay(15);
}
}
Experiment -DHT11 Sensor Interfacing with Arduino UNO
Construction
• DHT11 sensor measures and provides humidity
and temperature values serially over a single
wire.
• It can measure relative humidity in percentage
(20 to 90% RH) and temperature in degree
Celsius in the range of 0 to 50°C.
• It has 4 pins; one of which is used for data
communication in serial form.
• DHT11 sensor uses resistive humidity
measurement component, and NTC temperature
measurement component.
DHT11 Specifications

• Ultra-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
DHT22 Specifications
• Low cost
• 3 to 5V power and I/O
• 2.5mA max current use during conversion
(while requesting data)
• Good for 0-100% humidity readings with 2-5%
accuracy
• Good for -40 to 125°C temperature readings
±0.5°C accuracy
Timing diagram
• Before you can use the DHT11 on the Arduino, you’ll need to install the 
DHTLib library.

• https://github.com/adafruit/DHT-sensor-library

• It has all the functions needed to get the humidity and temperature


readings from the sensor.

• It’s easy to install, just download the DHTLib.zip and open up the Arduino
IDE.

• Then go to Sketch>Include Library>Add .ZIP Library and select the


DHTLib.zip file.
Remove Dependencies
https://github.com/adafruit/Adafruit_Sensor
• The following drivers exmples are based on
the Adafruit Unified Sensor Driver
#include <Adafruit_Sensor.h> void loop()
#include "DHT.h" {
#define DHTPIN 2 delay(2000);
#define DHTTYPE DHT11 float h = dht.readHumidity();
DHT dht(DHTPIN, DHTTYPE); float t = dht.readTemperature();
void setup() Serial.print("Humidity: \t" );
{ Serial.print(h);
Serial.begin(9600); Serial.print(" %\n");
Serial.println("DHT11 test!"); delay(500);
dht.begin(); Serial.print("Temperature: \t");
} Serial.print(t);
Serial.print(" *C \n");
}
1. WAP to make robotic arm moment for up and
down moment at elbow level.
2. WAP to automate the fan speed w.r.t to the room
temperature
3. WAP to control robotic arm using bluetooth.

You might also like