SlideShare a Scribd company logo
1 of 32
Download to read offline
WORKSHOP ON ARDUINO
DAY – 2: ADVANCE ARDUINO
DESIGN INNOVATION CENTRE
Activity 9 : DC Motor Speed & Direction Control
Motor:
An electric motor is an electrical machine that converts electrical
energy into mechanical energy. Most electric motors operate through the
interaction between the motor's magnetic field and electric current in a wire
winding to generate force in the form of rotation of a shaft.
DC Motor
The electric motor operated by direct current is called a DC Motor. This is a
device that converts DC electrical energy into a mechanical energy.
DC Motor Driver
What is Motor Driver?
 A motor driver IC is an integrated circuit chip
which is usually used to control motors in
autonomous robots.
 Motor driver ICs act as an interface between
the microprocessor and the motors in a robot.
 The most commonly used motor driver IC’s
are from the L293 series such as L293D,
L293NE, etc.
Why Motor Driver?
 Most microprocessors operate at low voltages
and require a small amount of current to
operate while the motors require a relatively
higher voltages and current .
 Thus current cannot be supplied to the motors
from the microprocessor.
 This is the primary need for the motor
driver IC.
Circuit Connections
Code & Explanation
/* Code for Dc Motor Speed &
Direction Control */
#define button 8
#define pot 0
#define pwm1 9
#define pwm2 10
boolean motor_dir = 0;
int motor_speed;
void setup() {
pinMode(pot, INPUT);
pinMode(button, INPUT_PULLUP);
pinMode(pwm1, OUTPUT);
pinMode(pwm2, OUTPUT);
Serial.begin(9600);
}
void loop() {
motor_speed = analogRead(pot);
Serial.println(pot);
if(motor_dir)
analogWrite(pwm1,
motor_speed);
else
analogWrite(pwm2,
motor_speed);
if(!digitalRead(button)){
while(!digitalRead(button));
motor_dir = !motor_dir;
if(motor_dir)
digitalWrite(pwm2, 0);
else
digitalWrite(pwm1, 0);
}
}
Activity 10 : Servo Motor
Servo Motor
 A servomotor is a rotary actuator or linear actuator that allows for precise
control of angular or linear position, velocity and acceleration.
 It consists of a suitable motor coupled to a sensor for position feedback.
 It also requires a relatively sophisticated controller, often a dedicated
module designed specifically for use with servomotors.
 Servo motor can be rotated from 0 to 180
degree.
 Servo motors are rated in kg/cm (kilogram per
centimeter) most servo motors are rated at
3kg/cm or 6kg/cm or 12kg/cm.
 This kg/cm tells you how much weight your
servo motor can lift at a particular distance.
For example: A 6kg/cm Servo motor should be
able to lift 6kg if load is suspended 1cm away
from the motors shaft, the greater the distance
the lesser the weight carrying capacity.
Circuit Connections
Code & Explanation
/* Program to control Servo Motor*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
Activity 11 : DHT11 Temperature & Humidity Sensor
Temperature & Humidity
 The degree or intensity of heat present in a substance or object is its
temperature.
 Humidity is the concentration of water vapour present in air.
 The temperature is measured with the
help of a NTC thermistor or negative
temperature coefficient thermistor.
 These thermistors are usually made with
semiconductors, ceramic and polymers.
 The humidity is sensed using a moisture
dependent resistor. It has two electrodes
and in between them there exist a
moisture holding substrate which holds
moisture.
 The conductance and hence resistance
changes with changing humidity.
PCB Size 22.0mm X 20.5mm X 1.6mm
Working Voltage 3.3 or 5V DC
Operating
Voltage
3.3 or 5V DC
Measure Range 20-95%RH;0-50℃
Resolution
8bit(temperature),
8bit(humidity)
Circuit Connections
Code & Explanation
// Program for DHT11
#include "dht.h"
#define dht_apin A0
// Pin sensor is connected to
dht DHT;
void setup(){
Serial.begin(9600);
delay(500); //Delay to let system boot
Serial.println("DHT11 Humidity &
temperature Sensornn");
delay(1000);
//Wait before accessing Sensor
} //end
void loop(){
//Start of Program
DHT.read11(dht_apin);
Serial.print("Current Humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("Temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");
delay(2000);
//Wait 2 seconds before accessing
sensor again.
//Fastest should be once every two
seconds.
} // end loop()
Activity 12 : Infrared Sensor
Infrared (IR) Communication
 Infrared (IR) is a wireless technology used for device communication over
short ranges. IR transceivers are quite cheap and serve as short-range
communication solution.
 Infrared band of the electromagnet corresponds to 430THz to 300GHz and a
wavelength of 980nm.
IR Sensor Module
 An IR sensor is a device which
detects IR radiation falling on it.
Applications:
Night Vision, Surveillance,
Thermography, Short – range
communication, Astronomy, etc.
Circuit Connections
Code & Explanation
// Program for IR Sensor to detect the
obstacle and indicate on the serial monitor
int LED = 13; // Use the onboard Uno LED
int obstaclePin = 7; // This is our input pin
int hasObstacle = HIGH;
// High Means No Obstacle
void setup() {
pinMode(LED, OUTPUT);
pinMode(obstaclePin, INPUT);
Serial.begin(9600);
}
void loop() {
hasObstacle = digitalRead(obstaclePin);
//Reads the output of the obstacle sensor
from the 7th PIN of the Digital section of
the arduino
if (hasObstacle == HIGH) {
//High means something is ahead, so
illuminates the 13th Port connected LED
Serial.println("Stop something is
ahead!!");
digitalWrite(LED, HIGH);
//Illuminates the 13th Port LED
}
else{
Serial.println("Path is clear");
digitalWrite(LED, LOW);
}
delay(200);
}
Activity 13 : Ultrasonic Sensor
Ultrasound
 Ultrasound is sound waves with frequencies higher than the upper audible
limit of human hearing.
Ultrasonic Sensor
 The Ultrasonic transmitter transmits an ultrasonic wave, this wave travels
in air and when it gets objected by any material it gets reflected back
toward the sensor this reflected wave is observed by the Ultrasonic
receiver.
Circuit Connections
Code & Explanation
// Program for Ultrasonic Sensor
const int trigPin = 9;
// defines pins numbers
const int echoPin = 10;
long duration; // defines variables
int distance;
void setup() {
pinMode(trigPin, OUTPUT);
// Sets the trigPin as an Output
pinMode(echoPin, INPUT);
// Sets the echoPin as an Input
Serial.begin(9600);
// Starts the serial communication
}
void loop() {
digitalWrite(trigPin, LOW);
// Clears the trigPin
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
// Sets the trigPin to HIGH for 10 µS
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
// Reads the echoPin, returns the sound
wave travel time in microseconds
distance= duration*0.034/2;
// Calculating the distance
Serial.print("Distance: "); // Prints the
distance on the Serial Monitor
Serial.println(distance);
delay(500);
}
Ultrasonic Distance Calculation
Do It Yourself - Line Follower
Line Follower
 Line follower is an autonomous robot which follows either black line in white
are or white line in black area.
Robot must be able to detect particular line and keep following it.
Concepts of Line Follower
 Concept of working of line follower is related to light.
 When light fall on a white surface it is almost fully reflected and in case of
black surface, light is completely absorbed. This behaviour of light is used
in building a line follower robot.
IR Sensor Principle
Block Diagram of Line Follower
Line Follower Working
Components
Line Follower Robot
Code & Explanation
//Arduino Line Follower
Code
void setup()
{
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop()
{
if(digitalRead(8) &&
digitalRead(9)) // Move
Forward
{
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}
if(!(digitalRead(8)) &&
digitalRead(9)) // Turn
right
{
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}
if(digitalRead(8) &&
!(digitalRead(9))) // turn
left
{
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
}
if(!(digitalRead(8)) &&
!(digitalRead(9))) // stop
{
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
}
}
Do It Yourself – Light Follower
Light Follower
A light follower robot is a light-seeking robot that moves toward areas of bright
light.
Light Dependent Resistor
An LDR is a component that has a (variable) resistance that changes with the
light intensity that falls upon it. This allows them to be used in light sensing
circuits.
Code & Explanation
//Light Follower Code
void setup() {
pinMode(A0,INPUT); //Right
Sensor output to arduino input
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensor=analogRead(A0);
delay(100);
Serial.println(sensor);
if (sensor >= 200){
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
}
else{
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
}
}
Do It Yourself – Obstacle Avoider
Obstacle Avoider
 This obstacle avoidance robot changes its path left or right depending on the
point of obstacles in its way.
 Here an Ultrasonic sensor is used to sense the obstacles in the path by
calculating the distance between the robot and obstacle. If robot finds any
obstacle it changes the direction and continue moving.
Applications:
 Mobile Robot Navigation
Systems,
 Automatic Vacuum Cleaning,
 Unmanned Aerial Vehicles,
etc.
Code & Explanation
const int trigPin = 9;
const int echoPin = 10;
void setup()
{
pinMode(trigPin,
OUTPUT);
pinMode(echoPin,
INPUT);
pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
Serial.begin(9600);
}
long duration, distance;
void loop()
{
digitalWrite(trigPin,
LOW);
delayMicroseconds(3);
digitalWrite(trigPin,
HIGH);
delayMicroseconds(12);
digitalWrite(trigPin,
LOW);
duration =
pulseIn(echoPin, HIGH);
distance = duration/58.2;
Serial.print(distance);
Serial.println("CM");
delay(10);
if(distance<20)
{
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}
else
{
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}
delay(90);
}
Recommended Books
Additional Resources
1. https://www.arduino.cc/ - Arduino.cc is the home of Arduino platform. It
has extensive learning materials such as Tutorials, References, code for
using Arduino, Forum where you can post questions on issues/problems
you have in your projects, etc.
2. http://makezine.com/ - Online page of Maker magazine, with lots of
information on innovative technology projects including Arduino.
3. http://www.instructables.com/ - Lots of projects on technology and arts
(including cooking), with step-by-instructions, photographs, and videos
4. http://appinventor.mit.edu/ - It allows the budding computer
programmers to build their own apps that can be run on Android devices. It
used a user-friendly graphical user-interface that allows drag-and-drop
technique to build applications that impacts the world.
5. http://fritzing.org/ - Fritzing is open source computer aided design (CAD)
software for electronic circuit design and printed circuit board (PCB)
fabrication, especially with Arduino prototyping. It is an electronic design
automation (EDA) tool for circuit designers.
Desgin Innovation Centre,
Indian Institute of Information Technology, Design &
Manufacturing, Kancheepuram, Chennai – 600127
E-mail: designinnovationcentre@gmail.com

More Related Content

What's hot

Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
Wingston
 

What's hot (20)

Arduino presentation by_warishusain
Arduino presentation by_warishusainArduino presentation by_warishusain
Arduino presentation by_warishusain
 
Introduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and ProgrammingIntroduction to Arduino Hardware and Programming
Introduction to Arduino Hardware and Programming
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Arduino
ArduinoArduino
Arduino
 
Arduino presentation
Arduino presentationArduino presentation
Arduino presentation
 
Arduino
ArduinoArduino
Arduino
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
PPT ON Arduino
PPT ON Arduino PPT ON Arduino
PPT ON Arduino
 
Arduino course
Arduino courseArduino course
Arduino course
 
Arduino
ArduinoArduino
Arduino
 
Arduino Microcontroller
Arduino MicrocontrollerArduino Microcontroller
Arduino Microcontroller
 
Introduction to Node MCU
Introduction to Node MCUIntroduction to Node MCU
Introduction to Node MCU
 
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauriArduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
 
L298 Motor Driver
L298 Motor DriverL298 Motor Driver
L298 Motor Driver
 
Arduino Uno Pin Description
Arduino Uno Pin DescriptionArduino Uno Pin Description
Arduino Uno Pin Description
 
Introduction to Arduino and Hands on to Iot
Introduction to Arduino and Hands on to IotIntroduction to Arduino and Hands on to Iot
Introduction to Arduino and Hands on to Iot
 
Nodemcu - introduction
Nodemcu - introductionNodemcu - introduction
Nodemcu - introduction
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 

Similar to Arduino Workshop Day 2 - Advance Arduino & DIY

Gulotta_Wright_Parisi_FinalProjectOverview1
Gulotta_Wright_Parisi_FinalProjectOverview1Gulotta_Wright_Parisi_FinalProjectOverview1
Gulotta_Wright_Parisi_FinalProjectOverview1
Nicholas Parisi
 

Similar to Arduino Workshop Day 2 - Advance Arduino & DIY (20)

Design and Development of a prototype of AGV
Design and Development of a prototype of AGVDesign and Development of a prototype of AGV
Design and Development of a prototype of AGV
 
INTELIGENT RAILWAY SYSTEM
INTELIGENT RAILWAY SYSTEMINTELIGENT RAILWAY SYSTEM
INTELIGENT RAILWAY SYSTEM
 
ACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CARACCELEROMETER BASED GESTURE ROBO CAR
ACCELEROMETER BASED GESTURE ROBO CAR
 
Automatic railway gate control using arduino uno
Automatic railway gate control using arduino unoAutomatic railway gate control using arduino uno
Automatic railway gate control using arduino uno
 
Arduino Based Collision Prevention Warning System
Arduino Based Collision Prevention Warning SystemArduino Based Collision Prevention Warning System
Arduino Based Collision Prevention Warning System
 
Interfacing with Atmega 16
Interfacing with Atmega 16Interfacing with Atmega 16
Interfacing with Atmega 16
 
AUTOMATIC RAILWAY GATE AND SIGNALLING SYSTEM
AUTOMATIC RAILWAY GATE AND SIGNALLING SYSTEMAUTOMATIC RAILWAY GATE AND SIGNALLING SYSTEM
AUTOMATIC RAILWAY GATE AND SIGNALLING SYSTEM
 
Multi-Function Automatic Move Smart Car for Arduino
Multi-Function Automatic Move Smart Car for ArduinoMulti-Function Automatic Move Smart Car for Arduino
Multi-Function Automatic Move Smart Car for Arduino
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
 
Rangefinder ppt
Rangefinder pptRangefinder ppt
Rangefinder ppt
 
438050190-presentation-for-arduino-driven-bluetooth-rc-cr.pptx
438050190-presentation-for-arduino-driven-bluetooth-rc-cr.pptx438050190-presentation-for-arduino-driven-bluetooth-rc-cr.pptx
438050190-presentation-for-arduino-driven-bluetooth-rc-cr.pptx
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
 
A project report on Remote Monitoring of a Power Station using GSM and Arduino
A project report on Remote Monitoring of a Power Station using GSM and ArduinoA project report on Remote Monitoring of a Power Station using GSM and Arduino
A project report on Remote Monitoring of a Power Station using GSM and Arduino
 
POSITION ANALYSIS OF DIGITAL SYSTEM
POSITION ANALYSIS OF DIGITAL SYSTEMPOSITION ANALYSIS OF DIGITAL SYSTEM
POSITION ANALYSIS OF DIGITAL SYSTEM
 
Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...
Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...
Microcontroller based Ultrasonic Radar (Microprocessors and Embedded Systems ...
 
Metal Detector Robotic Vehicle
Metal Detector Robotic VehicleMetal Detector Robotic Vehicle
Metal Detector Robotic Vehicle
 
Gulotta_Wright_Parisi_FinalProjectOverview1
Gulotta_Wright_Parisi_FinalProjectOverview1Gulotta_Wright_Parisi_FinalProjectOverview1
Gulotta_Wright_Parisi_FinalProjectOverview1
 
DC MOTOR SPEED CONTROL USING ON-OFF CONTROLLER BY PIC16F877A MICROCONTROLLER
DC MOTOR SPEED CONTROL USING ON-OFF CONTROLLER BY  PIC16F877A MICROCONTROLLERDC MOTOR SPEED CONTROL USING ON-OFF CONTROLLER BY  PIC16F877A MICROCONTROLLER
DC MOTOR SPEED CONTROL USING ON-OFF CONTROLLER BY PIC16F877A MICROCONTROLLER
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 

Arduino Workshop Day 2 - Advance Arduino & DIY

  • 1. WORKSHOP ON ARDUINO DAY – 2: ADVANCE ARDUINO DESIGN INNOVATION CENTRE
  • 2. Activity 9 : DC Motor Speed & Direction Control Motor: An electric motor is an electrical machine that converts electrical energy into mechanical energy. Most electric motors operate through the interaction between the motor's magnetic field and electric current in a wire winding to generate force in the form of rotation of a shaft. DC Motor The electric motor operated by direct current is called a DC Motor. This is a device that converts DC electrical energy into a mechanical energy.
  • 3. DC Motor Driver What is Motor Driver?  A motor driver IC is an integrated circuit chip which is usually used to control motors in autonomous robots.  Motor driver ICs act as an interface between the microprocessor and the motors in a robot.  The most commonly used motor driver IC’s are from the L293 series such as L293D, L293NE, etc. Why Motor Driver?  Most microprocessors operate at low voltages and require a small amount of current to operate while the motors require a relatively higher voltages and current .  Thus current cannot be supplied to the motors from the microprocessor.  This is the primary need for the motor driver IC.
  • 5. Code & Explanation /* Code for Dc Motor Speed & Direction Control */ #define button 8 #define pot 0 #define pwm1 9 #define pwm2 10 boolean motor_dir = 0; int motor_speed; void setup() { pinMode(pot, INPUT); pinMode(button, INPUT_PULLUP); pinMode(pwm1, OUTPUT); pinMode(pwm2, OUTPUT); Serial.begin(9600); } void loop() { motor_speed = analogRead(pot); Serial.println(pot); if(motor_dir) analogWrite(pwm1, motor_speed); else analogWrite(pwm2, motor_speed); if(!digitalRead(button)){ while(!digitalRead(button)); motor_dir = !motor_dir; if(motor_dir) digitalWrite(pwm2, 0); else digitalWrite(pwm1, 0); } }
  • 6. Activity 10 : Servo Motor Servo Motor  A servomotor is a rotary actuator or linear actuator that allows for precise control of angular or linear position, velocity and acceleration.  It consists of a suitable motor coupled to a sensor for position feedback.  It also requires a relatively sophisticated controller, often a dedicated module designed specifically for use with servomotors.  Servo motor can be rotated from 0 to 180 degree.  Servo motors are rated in kg/cm (kilogram per centimeter) most servo motors are rated at 3kg/cm or 6kg/cm or 12kg/cm.  This kg/cm tells you how much weight your servo motor can lift at a particular distance. For example: A 6kg/cm Servo motor should be able to lift 6kg if load is suspended 1cm away from the motors shaft, the greater the distance the lesser the weight carrying capacity.
  • 8. Code & Explanation /* Program to control Servo Motor*/ #include <Servo.h> Servo myservo; // create servo object to control a servo int pos = 0; // variable to store the servo position void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } }
  • 9. Activity 11 : DHT11 Temperature & Humidity Sensor Temperature & Humidity  The degree or intensity of heat present in a substance or object is its temperature.  Humidity is the concentration of water vapour present in air.  The temperature is measured with the help of a NTC thermistor or negative temperature coefficient thermistor.  These thermistors are usually made with semiconductors, ceramic and polymers.  The humidity is sensed using a moisture dependent resistor. It has two electrodes and in between them there exist a moisture holding substrate which holds moisture.  The conductance and hence resistance changes with changing humidity. PCB Size 22.0mm X 20.5mm X 1.6mm Working Voltage 3.3 or 5V DC Operating Voltage 3.3 or 5V DC Measure Range 20-95%RH;0-50℃ Resolution 8bit(temperature), 8bit(humidity)
  • 11. Code & Explanation // Program for DHT11 #include "dht.h" #define dht_apin A0 // Pin sensor is connected to dht DHT; void setup(){ Serial.begin(9600); delay(500); //Delay to let system boot Serial.println("DHT11 Humidity & temperature Sensornn"); delay(1000); //Wait before accessing Sensor } //end void loop(){ //Start of Program DHT.read11(dht_apin); Serial.print("Current Humidity = "); Serial.print(DHT.humidity); Serial.print("% "); Serial.print("Temperature = "); Serial.print(DHT.temperature); Serial.println("C "); delay(2000); //Wait 2 seconds before accessing sensor again. //Fastest should be once every two seconds. } // end loop()
  • 12. Activity 12 : Infrared Sensor Infrared (IR) Communication  Infrared (IR) is a wireless technology used for device communication over short ranges. IR transceivers are quite cheap and serve as short-range communication solution.  Infrared band of the electromagnet corresponds to 430THz to 300GHz and a wavelength of 980nm. IR Sensor Module  An IR sensor is a device which detects IR radiation falling on it. Applications: Night Vision, Surveillance, Thermography, Short – range communication, Astronomy, etc.
  • 14. Code & Explanation // Program for IR Sensor to detect the obstacle and indicate on the serial monitor int LED = 13; // Use the onboard Uno LED int obstaclePin = 7; // This is our input pin int hasObstacle = HIGH; // High Means No Obstacle void setup() { pinMode(LED, OUTPUT); pinMode(obstaclePin, INPUT); Serial.begin(9600); } void loop() { hasObstacle = digitalRead(obstaclePin); //Reads the output of the obstacle sensor from the 7th PIN of the Digital section of the arduino if (hasObstacle == HIGH) { //High means something is ahead, so illuminates the 13th Port connected LED Serial.println("Stop something is ahead!!"); digitalWrite(LED, HIGH); //Illuminates the 13th Port LED } else{ Serial.println("Path is clear"); digitalWrite(LED, LOW); } delay(200); }
  • 15. Activity 13 : Ultrasonic Sensor Ultrasound  Ultrasound is sound waves with frequencies higher than the upper audible limit of human hearing. Ultrasonic Sensor  The Ultrasonic transmitter transmits an ultrasonic wave, this wave travels in air and when it gets objected by any material it gets reflected back toward the sensor this reflected wave is observed by the Ultrasonic receiver.
  • 17. Code & Explanation // Program for Ultrasonic Sensor const int trigPin = 9; // defines pins numbers const int echoPin = 10; long duration; // defines variables int distance; void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input Serial.begin(9600); // Starts the serial communication } void loop() { digitalWrite(trigPin, LOW); // Clears the trigPin delayMicroseconds(2); digitalWrite(trigPin, HIGH); // Sets the trigPin to HIGH for 10 µS delayMicroseconds(10); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel time in microseconds distance= duration*0.034/2; // Calculating the distance Serial.print("Distance: "); // Prints the distance on the Serial Monitor Serial.println(distance); delay(500); }
  • 19. Do It Yourself - Line Follower Line Follower  Line follower is an autonomous robot which follows either black line in white are or white line in black area. Robot must be able to detect particular line and keep following it. Concepts of Line Follower  Concept of working of line follower is related to light.  When light fall on a white surface it is almost fully reflected and in case of black surface, light is completely absorbed. This behaviour of light is used in building a line follower robot.
  • 21. Block Diagram of Line Follower
  • 25. Code & Explanation //Arduino Line Follower Code void setup() { pinMode(8, INPUT); pinMode(9, INPUT); pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); } void loop() { if(digitalRead(8) && digitalRead(9)) // Move Forward { digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, HIGH); digitalWrite(5, LOW); } if(!(digitalRead(8)) && digitalRead(9)) // Turn right { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, HIGH); digitalWrite(5, LOW); } if(digitalRead(8) && !(digitalRead(9))) // turn left { digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); } if(!(digitalRead(8)) && !(digitalRead(9))) // stop { digitalWrite(2, LOW); digitalWrite(3, LOW); digitalWrite(4, LOW); digitalWrite(5, LOW); } }
  • 26. Do It Yourself – Light Follower Light Follower A light follower robot is a light-seeking robot that moves toward areas of bright light. Light Dependent Resistor An LDR is a component that has a (variable) resistance that changes with the light intensity that falls upon it. This allows them to be used in light sensing circuits.
  • 27. Code & Explanation //Light Follower Code void setup() { pinMode(A0,INPUT); //Right Sensor output to arduino input pinMode(2,OUTPUT); pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); Serial.begin(9600); } void loop() { int sensor=analogRead(A0); delay(100); Serial.println(sensor); if (sensor >= 200){ digitalWrite(2,HIGH); digitalWrite(3,LOW); digitalWrite(4,HIGH); digitalWrite(5,LOW); } else{ digitalWrite(2,LOW); digitalWrite(3,LOW); digitalWrite(4,LOW); digitalWrite(5,LOW); } }
  • 28. Do It Yourself – Obstacle Avoider Obstacle Avoider  This obstacle avoidance robot changes its path left or right depending on the point of obstacles in its way.  Here an Ultrasonic sensor is used to sense the obstacles in the path by calculating the distance between the robot and obstacle. If robot finds any obstacle it changes the direction and continue moving. Applications:  Mobile Robot Navigation Systems,  Automatic Vacuum Cleaning,  Unmanned Aerial Vehicles, etc.
  • 29. Code & Explanation const int trigPin = 9; const int echoPin = 10; void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode (2, OUTPUT); pinMode (3, OUTPUT); pinMode (4, OUTPUT); pinMode (5, OUTPUT); Serial.begin(9600); } long duration, distance; void loop() { digitalWrite(trigPin, LOW); delayMicroseconds(3); digitalWrite(trigPin, HIGH); delayMicroseconds(12); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = duration/58.2; Serial.print(distance); Serial.println("CM"); delay(10); if(distance<20) { digitalWrite(2, LOW); digitalWrite(3, HIGH); digitalWrite(4, HIGH); digitalWrite(5, LOW); } else { digitalWrite(2, HIGH); digitalWrite(3, LOW); digitalWrite(4, HIGH); digitalWrite(5, LOW); } delay(90); }
  • 31. Additional Resources 1. https://www.arduino.cc/ - Arduino.cc is the home of Arduino platform. It has extensive learning materials such as Tutorials, References, code for using Arduino, Forum where you can post questions on issues/problems you have in your projects, etc. 2. http://makezine.com/ - Online page of Maker magazine, with lots of information on innovative technology projects including Arduino. 3. http://www.instructables.com/ - Lots of projects on technology and arts (including cooking), with step-by-instructions, photographs, and videos 4. http://appinventor.mit.edu/ - It allows the budding computer programmers to build their own apps that can be run on Android devices. It used a user-friendly graphical user-interface that allows drag-and-drop technique to build applications that impacts the world. 5. http://fritzing.org/ - Fritzing is open source computer aided design (CAD) software for electronic circuit design and printed circuit board (PCB) fabrication, especially with Arduino prototyping. It is an electronic design automation (EDA) tool for circuit designers.
  • 32. Desgin Innovation Centre, Indian Institute of Information Technology, Design & Manufacturing, Kancheepuram, Chennai – 600127 E-mail: designinnovationcentre@gmail.com