SlideShare a Scribd company logo
1 of 37
Temperature sensors
0 Gives a Vout propotional to ambient room
 temperature.

0 Concept : as temperature increases, voltage
 across a p-n junction increases at a known
 rate. (in this case Vbe)

0 Voltage at Anlg.Pin in Volts = (reading
  from ADC) * (5/1024) V
0 Centigrade temperature = [(analog voltage
  in V) – 0.5] * 100
Before: Writing the code
0 Review:
   0 How does the lm35 work?
   0 Read datasheet of lm35.
   0 How to connect it to arduino?
   0 What reference to use?
   0 What sort of noises will be present?
   0 What does the analogue input signify?
Datasheet of LM35
Circuit connection diagram
Temp sensor code
0 Connect lm35 as per circuit diagram in 7. Temp Sensor
 folder.

0 We’re giving AREF as 3.3V to reduce noise from the
 LM35 and give more accurate readings.

0 Upload code onto Arduino and Output is seen in the
 Serial monitor of the Arduino.
Write the code
1. Decide which analogue pin you’re going to and
     assign it to a global variable
2.   in setup() { }, initialize serial port to 9600 baud rate
     to send temp reading out to PC.
3.   In loop() { }, take the analogue reading from a pin
     and store it in a temp float variable.
4.   Multiply reading by 5.0 and then divide by 1024 to
     get voltage value read by the port. Store this is a
     float variable called volt.
5.   Print out this value to the serial port and check.
Keep Writing the code
0 To get temp in centigrade, (volt – 0.5) * 100

0 This is the ambient temperature recognized by the
 LM35 in Celsius.

0 Send it to the serial port and check your code.

0 To convert to fahrenheight, mult by 9 then divide by 5
 then add 32 to that result. Send it to serial port too.

              0 Congratulate yourself please.
Improvements?
0 Use 3.3V as reference to increase resolution since
 datasheet says that resolution of lm35 ~ 10mV.

0 Put in on PCB to avoid noise by breadboard internal
 resistance,

0 DO NOT LIGHT THE LM35 OR IMMERSE IT IN WATER.

0 Make a waterproof casing for the lm35 to test temp of
 liquids.

0 Any other applications?
LDR
0 An LDR is a Light Dependent Resistor.
0 As in the resistance offered by this device to an
 electrical circuit is dependent on the amount of light
 falling on the circuit.

0 Also called photocells because they convert light
 energy to an electrical response.

0 Useful for on-when-light/off-when-dark.
How to connect the LDR
0 LDR is basically a resistor, so it can be connected
  anyway.

0 You need a pull-down resistor to avoid sinking all the
  current onto the arduino pin.

0 Circuit is GND-10kohn-LDR-VCC.

0 This circuit will only work if between 0-5V. If light is
  too bright, it will saturate at 5V.
0 putting a variable resistor in place of 10k allows for
  controlling saturation with too bright/too dark light.
Photocell               Current
Ambient       Ambient                    LDR + R               Voltage
                            resistance              thru LDR
light like…   light (lux)                (Ω)                   across R
                            (Ω)                     +R
Dim
              0.1 lux       600KΩ        610 KΩ     0.008 mA   0.1 V
hallway
Moonlit
              1 lux         70 KΩ        80 KΩ      0.07 mA    0.6 V
night
Room          10 lux        10 KΩ        20 KΩ      0.25 mA    2.5 V
Dark
overcast
day /         100 lux       1.5 KΩ       11.5 KΩ    0.43 mA    4.3 V
Bright
room
Overcast
              1000 lux      300 Ω        10.03 KΩ   0.5 mA     5V
day
Writing code!
0 decide analoge pin used as input to LDR.

0 In setup(){ }, initialize serial port with 9600.

0 In loop(){ }, first do an analogueread(pin) and store it in an
  int variable called reading.

0 This value represents illumination received by LDR.
0 Send it to Serial Port.

0 Allow delay of some time to let the ADC settle.
Application 1
0 Make thresholds and determine the brightness
 received and send it via serial port.




if (reading < 10)              { Serial.println(" - Dark"); }
else if (reading < 200)        { Serial.println(" - Dim"); }
else if (reading < 500)        { Serial.println(" - Light"); }
else if (reading < 800)        { Serial.println(" - Bright"); }
else { Serial.println(" - Very bright"); }
Application 2
0 Take the analogue reading and use it as the delay
 amount in an LED blinking scenario. Use ledpin = 13.

void loop()
 {
         val = analogRead(LDR);
         digitalWrite(ledPin, HIGH);
         delay(val);
         digitalWrite(ledPin, LOW);
         delay(val);
}
Another Application
0 Put three LEDs around the LDR. Red, Green and Blue.

0 Put an object of a particular color in front of the LDR.

0 Light up RED LED and measure LDR value
0 Light up GREEN LED and measure LDR value
0 Light up BLUE LED and measure LDR value

0 From these three analogue values you can determine the
  color of object being sensed.
Sensor Data on PC
0 Reading and plotting sensor data on PC is very simple
 on the arduino.

0 Send data continuously to the computer over the
 serial port.

0 Data can be viewed by any program capable of
 viewing this data
Send sensor data to serial
            port
0 Open the folder Sensor data graph

0 Upload the arduino code onto the arduino and close
 arduino IDE after checking serial monitor.

0 In softwares folder extract the processing folder.

0 Open processing and copy the processing code onto it and
 run.

0 Make sure serial port number in the processing sketch
 matches arduino
The motor shield
                                             The motor shield goes on top
1. DC Motor Interface                        of the arduino neatly.
Drives 2 motors with L293D DC Motor
Driver IC.
                                             There are loads of shields for
                                             the arduino that provide
2. IR paired sensors
                                             different functionality.
For line sensing, 4 IR sensor pairs can be
attached and controlled.
                                             Be careful removing the
                                             shield, if you bend the pins,
3. The Buzzer or Servo Motor
                                             you cant put the shield in
Selectable via jumper
                                             again.
4. The Switch or Servo Motor
Selectable via jumper

5. Two LEDs
IR TX RX Pair
0 An IR transmitter (TX) is a LED that emits
  light in the infrared spectrum.
0 (most cameras see IR, light up the IR LED
  and point a camera at it to check)

0 An IR Receiver (RX) is a transistor with the
  base exposed.
0 The base voltage depends on the amount of
  IR received and it controls the amount of
  current passing through the C-E junction
  (leads).
IR schematic
0 The IR TX LED is connected through a current
  limiting resisto
0 The IR RX is connected via a variable potentiometer
  to a voltage comparator to give a digital output.

0 The pot is used to adjust
For ambient light intensity.
Remember
0 The IR TX RX pairs should be spaced 1/4th of an inch apart
  for optimal detection.

0 Calibration of IR sensors is important to adjust the sensors
  for ambient light.

0 The output of this circuit is DIGITAL and read by a digital
  pin. 1 – obstruction; 0 – No obstruction.

0 If you have to use IR sensors in the sun, use electrical tape
  to provide adequate shielding.
Using the IR sensors
0 The motor shield has 4 IR sensors and 4 pots.
0 Connect the IR dongles to the placeholders. They go in only
  one way
0 There are status LEDs just next to each IR socket, if the
  comparator goes HIGH, the LED lights. This is for
  calibration.
0 Keep the IR sensor pointed at nothing (no obstruction).
0 Use a screwdriver and GENTLY turn the appropriate POT
  until the respective IR sensors status LED turns dark.
0 Check with your hand if LED lights, if not readjust as you
  like.
PINS
0 The table below shows the pin arrangement for the 4
 sensors on the shield.

0 If the shield is mounted, then these 4 pins provide the
 output of the comparator.

0 Use digitalread(pin) to see the state of the pin at any
 time.
Try
0 Connect all four IR sensors and calibrate them.

0 Write a program to output which of the 4 IR sensors
 has gone HIGH to the serial port.

0 CHALLENGE: Try and make sure that the message on
 the serial port doesn’t repeat until the IR sensor has
 gone LOW again (obstruction removed). It shouldn't
 continuously output the message if the IR sensor is
 obstructed,
DC motors
0 Motors are devices that convert electrical energy to
 mechanical energy.

0 Motors come in different varieties: AC, DC, Servo, Stepper
 etc

0 If motor draws less than 40mA of current, it can be directlu
 wired to an arduino pin.

0 Current drawn by a DC motor is propotional to speed and
 torque. To avoid burning out the arduino, we use motor
 drivers to control DC motors.
The L293 driver
0 This chip isolates logic level voltages and the motor supply
  voltages.

0 It as also called a H-bridge.


0 It uses the transistors as a switch concept to electrically
  switch a DC power supply onto the terminals of the motor.

0 The driver can control two motors independently from the
  same supply.
Motor Driver
The Motor Shield
0 The motor driver is present on the
 shield which also contains a wire
 block for easy connection of the
 wires.

0 The supply will have terminals
 marked on the board. Do not reverse      -
 these connections.                       +

0 Motor can be connected in anyway.
 The direction might have to be
 calibrated by testing if the terminals
 are reversed.
Arduino shield to Motor
         Driver Pinout
0 To use a motor, set the enable pin to high in the setup() { }

0 Motor movement is done in loop() { }
0 If l1 is HIGH and l2 is LOW, motor turn in one direction.
0 If l1 is LOW and l2 is HIGH, the motor turns in the other
  direction.

0 If both l1 and l2 are set to HIGH or LOW, then motor is stopped.
Wiring motors
0 Attach the arduino shield onto the arduino.


0 Take a 9V battery cap and screw it onto the motor
 supply terminals. Take care of polarity.
  0 Red >> + and Black >> -


0 Wire up the motors and connect them to the
 terminals.
TRY
0 Move both motors in same direction.


0 Reverse both motors.


0 Stop one and turn the other.
0 Stop the other and turn the one.


0 Make each motor turn in a different direction.
Exercise
0 Combine the functionality of 2 IR sensors and the
  motors to make an obstacle avoider bot.

0 Algorith:
   0 Move forward, left and right randomly.
   0 If IR sensors detect an obstruction, move a little back in
     the opposite side of the obstruction
   0 Continue.

More Related Content

What's hot

DHT11 Digital Temperature and Humidity Sensor
DHT11 Digital Temperature and Humidity SensorDHT11 Digital Temperature and Humidity Sensor
DHT11 Digital Temperature and Humidity SensorRaghav Shetty
 
Build your own electronics lab
Build your own electronics labBuild your own electronics lab
Build your own electronics labKarim El-Rayes
 
protection on lineman while working on transmission line report
 protection on lineman while working on transmission line report protection on lineman while working on transmission line report
protection on lineman while working on transmission line reportRavi Phadtare
 
Arduino - Ch 2: Sunrise-Sunset Light Switch
Arduino - Ch 2: Sunrise-Sunset Light SwitchArduino - Ch 2: Sunrise-Sunset Light Switch
Arduino - Ch 2: Sunrise-Sunset Light SwitchRatzman III
 
Physical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensorsPhysical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensorsTony Olsson.
 
Automatic Room Lock And Lights Off Circuit
Automatic Room Lock And Lights Off CircuitAutomatic Room Lock And Lights Off Circuit
Automatic Room Lock And Lights Off CircuitAmrish Tejas
 
Electronics schematic circuits for the hobbyist
Electronics schematic circuits for the hobbyistElectronics schematic circuits for the hobbyist
Electronics schematic circuits for the hobbyistben kamau
 
Sensor interfacing in 8051
Sensor interfacing in 8051Sensor interfacing in 8051
Sensor interfacing in 8051Irfan Ahmad
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentIJERD Editor
 
Home automationusing ir remote
Home automationusing ir remote Home automationusing ir remote
Home automationusing ir remote Rohith Kilkile
 
DHT11 with Arduino
DHT11 with ArduinoDHT11 with Arduino
DHT11 with Arduinoyeokm1
 
Operating electrical devices with PIR sensor. No coding, No controller
Operating electrical devices with PIR sensor. No coding, No controllerOperating electrical devices with PIR sensor. No coding, No controller
Operating electrical devices with PIR sensor. No coding, No controllerSantosh Kumar Kar
 
Sensor Lecture Interfacing
 Sensor Lecture Interfacing Sensor Lecture Interfacing
Sensor Lecture Interfacingutpal sarkar
 
Arduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick SwitchArduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick SwitchRatzman III
 
Arduino Water level tank with Ultrasonic sensor
Arduino Water level tank with Ultrasonic sensorArduino Water level tank with Ultrasonic sensor
Arduino Water level tank with Ultrasonic sensorArip Rahman Hakim
 
Automatic doorbell with object detection
Automatic doorbell with object detectionAutomatic doorbell with object detection
Automatic doorbell with object detectionAnurag Alaria
 
Wireless transmission of voice signal using nRF24L01 module
Wireless transmission of voice signal using nRF24L01 moduleWireless transmission of voice signal using nRF24L01 module
Wireless transmission of voice signal using nRF24L01 moduleSunil Kumar Shesma
 

What's hot (20)

DHT11 Digital Temperature and Humidity Sensor
DHT11 Digital Temperature and Humidity SensorDHT11 Digital Temperature and Humidity Sensor
DHT11 Digital Temperature and Humidity Sensor
 
Build your own electronics lab
Build your own electronics labBuild your own electronics lab
Build your own electronics lab
 
protection on lineman while working on transmission line report
 protection on lineman while working on transmission line report protection on lineman while working on transmission line report
protection on lineman while working on transmission line report
 
Arduino - Ch 2: Sunrise-Sunset Light Switch
Arduino - Ch 2: Sunrise-Sunset Light SwitchArduino - Ch 2: Sunrise-Sunset Light Switch
Arduino - Ch 2: Sunrise-Sunset Light Switch
 
Physical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensorsPhysical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensors
 
Automatic Room Lock And Lights Off Circuit
Automatic Room Lock And Lights Off CircuitAutomatic Room Lock And Lights Off Circuit
Automatic Room Lock And Lights Off Circuit
 
Electronics schematic circuits for the hobbyist
Electronics schematic circuits for the hobbyistElectronics schematic circuits for the hobbyist
Electronics schematic circuits for the hobbyist
 
Sensor interfacing in 8051
Sensor interfacing in 8051Sensor interfacing in 8051
Sensor interfacing in 8051
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
Home automationusing ir remote
Home automationusing ir remote Home automationusing ir remote
Home automationusing ir remote
 
DHT11 with Arduino
DHT11 with ArduinoDHT11 with Arduino
DHT11 with Arduino
 
Operating electrical devices with PIR sensor. No coding, No controller
Operating electrical devices with PIR sensor. No coding, No controllerOperating electrical devices with PIR sensor. No coding, No controller
Operating electrical devices with PIR sensor. No coding, No controller
 
Sensor Lecture Interfacing
 Sensor Lecture Interfacing Sensor Lecture Interfacing
Sensor Lecture Interfacing
 
Arduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick SwitchArduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick Switch
 
Arduino Water level tank with Ultrasonic sensor
Arduino Water level tank with Ultrasonic sensorArduino Water level tank with Ultrasonic sensor
Arduino Water level tank with Ultrasonic sensor
 
digi mul ppt
digi mul pptdigi mul ppt
digi mul ppt
 
Automatic doorbell with object detection
Automatic doorbell with object detectionAutomatic doorbell with object detection
Automatic doorbell with object detection
 
Wireless transmission of voice signal using nRF24L01 module
Wireless transmission of voice signal using nRF24L01 moduleWireless transmission of voice signal using nRF24L01 module
Wireless transmission of voice signal using nRF24L01 module
 
Wireless sensors
Wireless sensorsWireless sensors
Wireless sensors
 
Anti theft & Automation using Arduino
Anti theft & Automation using ArduinoAnti theft & Automation using Arduino
Anti theft & Automation using Arduino
 

Viewers also liked

introduction of Gsm
introduction of Gsmintroduction of Gsm
introduction of GsmAhmed Nasser
 
Arduino e-Course Syllabus for Beginners
Arduino e-Course Syllabus for BeginnersArduino e-Course Syllabus for Beginners
Arduino e-Course Syllabus for BeginnersMadhu Honey
 
Arduino workshop proposal
Arduino workshop proposalArduino workshop proposal
Arduino workshop proposalfreemanindia
 
Embedded system development-Arduino UNO
Embedded system development-Arduino UNOEmbedded system development-Arduino UNO
Embedded system development-Arduino UNOayush sultania
 
Arduino Robotics workshop Day1
Arduino Robotics workshop Day1Arduino Robotics workshop Day1
Arduino Robotics workshop Day1Sudar Muthu
 
Introduction to GSM - an Overview of Global System for Mobile Communication
Introduction to GSM - an Overview of Global System for Mobile CommunicationIntroduction to GSM - an Overview of Global System for Mobile Communication
Introduction to GSM - an Overview of Global System for Mobile Communicationiptvmagazine
 
Project presentation on wireless lpg leakage detector
Project presentation on wireless lpg leakage detectorProject presentation on wireless lpg leakage detector
Project presentation on wireless lpg leakage detectorPETER ASIGRI
 
Vehicle tracking system using gps and gsm
Vehicle tracking system using gps and gsmVehicle tracking system using gps and gsm
Vehicle tracking system using gps and gsmanita maharjan
 
Gps tracking system
Gps tracking system Gps tracking system
Gps tracking system Sumit Kumar
 
Gsm.....ppt
Gsm.....pptGsm.....ppt
Gsm.....pptbalu008
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESDr.YNM
 
Gas Leakage Detector using Arduino with SMS Alert - Engineering Project
Gas Leakage Detector using Arduino with SMS Alert - Engineering ProjectGas Leakage Detector using Arduino with SMS Alert - Engineering Project
Gas Leakage Detector using Arduino with SMS Alert - Engineering ProjectCircuitsToday
 

Viewers also liked (20)

introduction of Gsm
introduction of Gsmintroduction of Gsm
introduction of Gsm
 
Unit vi (1)
Unit vi (1)Unit vi (1)
Unit vi (1)
 
Arduino e-Course Syllabus for Beginners
Arduino e-Course Syllabus for BeginnersArduino e-Course Syllabus for Beginners
Arduino e-Course Syllabus for Beginners
 
Unit vi (2)
Unit vi (2)Unit vi (2)
Unit vi (2)
 
Sim900
Sim900Sim900
Sim900
 
Arduino workshop proposal
Arduino workshop proposalArduino workshop proposal
Arduino workshop proposal
 
PIC_ARM_AVR
PIC_ARM_AVRPIC_ARM_AVR
PIC_ARM_AVR
 
Embedded system development-Arduino UNO
Embedded system development-Arduino UNOEmbedded system development-Arduino UNO
Embedded system development-Arduino UNO
 
Arduino Robotics workshop Day1
Arduino Robotics workshop Day1Arduino Robotics workshop Day1
Arduino Robotics workshop Day1
 
GSM Module
GSM ModuleGSM Module
GSM Module
 
Introduction to GSM - an Overview of Global System for Mobile Communication
Introduction to GSM - an Overview of Global System for Mobile CommunicationIntroduction to GSM - an Overview of Global System for Mobile Communication
Introduction to GSM - an Overview of Global System for Mobile Communication
 
Project presentation on wireless lpg leakage detector
Project presentation on wireless lpg leakage detectorProject presentation on wireless lpg leakage detector
Project presentation on wireless lpg leakage detector
 
8051 Presentation
8051 Presentation8051 Presentation
8051 Presentation
 
GSM Presentation
GSM PresentationGSM Presentation
GSM Presentation
 
Vehicle tracking system using gps and gsm
Vehicle tracking system using gps and gsmVehicle tracking system using gps and gsm
Vehicle tracking system using gps and gsm
 
Gps tracking system
Gps tracking system Gps tracking system
Gps tracking system
 
Gps ppt
Gps pptGps ppt
Gps ppt
 
Gsm.....ppt
Gsm.....pptGsm.....ppt
Gsm.....ppt
 
PIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTESPIC MICROCONTROLLERS -CLASS NOTES
PIC MICROCONTROLLERS -CLASS NOTES
 
Gas Leakage Detector using Arduino with SMS Alert - Engineering Project
Gas Leakage Detector using Arduino with SMS Alert - Engineering ProjectGas Leakage Detector using Arduino with SMS Alert - Engineering Project
Gas Leakage Detector using Arduino with SMS Alert - Engineering Project
 

Similar to 04 Arduino Peripheral Interfacing

Raspberry pi Part 18
Raspberry pi Part 18Raspberry pi Part 18
Raspberry pi Part 18Techvilla
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalTony Olsson.
 
To measure the intensity of light using LDR sensor by calibrating voltage wit...
To measure the intensity of light using LDR sensor by calibrating voltage wit...To measure the intensity of light using LDR sensor by calibrating voltage wit...
To measure the intensity of light using LDR sensor by calibrating voltage wit...Ankita Tiwari
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC MicrocontrollerDivya Bansal
 
Automatic street light using ldr and relay
Automatic street light using ldr and relayAutomatic street light using ldr and relay
Automatic street light using ldr and relayShivam Raidas
 
Electronz_Chapter_4.pptx
Electronz_Chapter_4.pptxElectronz_Chapter_4.pptx
Electronz_Chapter_4.pptxMokete5
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptxHebaEng
 
Therft alert system
Therft alert systemTherft alert system
Therft alert systemBadal Tushar
 
Fire Fighting Robot
Fire Fighting RobotFire Fighting Robot
Fire Fighting RobotSaadullah74
 
70 interesting circuits
70 interesting circuits70 interesting circuits
70 interesting circuitsvietem0610
 
LIGHT DETECTOR USING NAND GATE
LIGHT DETECTOR USING NAND GATELIGHT DETECTOR USING NAND GATE
LIGHT DETECTOR USING NAND GATEabdullahkhalid50
 
LDR (LIGHT DEPENDENT RESISTOR)
LDR (LIGHT DEPENDENT RESISTOR)LDR (LIGHT DEPENDENT RESISTOR)
LDR (LIGHT DEPENDENT RESISTOR)Nelarapu Mahesh
 
Sensitive intrucer alaram
Sensitive intrucer alaramSensitive intrucer alaram
Sensitive intrucer alaramSai Kumar
 
70 interesting circuits
70 interesting circuits70 interesting circuits
70 interesting circuitsivan ion
 

Similar to 04 Arduino Peripheral Interfacing (20)

Raspberry pi Part 18
Raspberry pi Part 18Raspberry pi Part 18
Raspberry pi Part 18
 
Microcontroller ppt
Microcontroller pptMicrocontroller ppt
Microcontroller ppt
 
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
 
To measure the intensity of light using LDR sensor by calibrating voltage wit...
To measure the intensity of light using LDR sensor by calibrating voltage wit...To measure the intensity of light using LDR sensor by calibrating voltage wit...
To measure the intensity of light using LDR sensor by calibrating voltage wit...
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC Microcontroller
 
Arch
ArchArch
Arch
 
Automatic street light using ldr and relay
Automatic street light using ldr and relayAutomatic street light using ldr and relay
Automatic street light using ldr and relay
 
Electronz_Chapter_4.pptx
Electronz_Chapter_4.pptxElectronz_Chapter_4.pptx
Electronz_Chapter_4.pptx
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptx
 
Therft alert system
Therft alert systemTherft alert system
Therft alert system
 
Measurements upload
Measurements uploadMeasurements upload
Measurements upload
 
Fire Fighting Robot
Fire Fighting RobotFire Fighting Robot
Fire Fighting Robot
 
70 interesting circuits
70 interesting circuits70 interesting circuits
70 interesting circuits
 
LIGHT DETECTOR USING NAND GATE
LIGHT DETECTOR USING NAND GATELIGHT DETECTOR USING NAND GATE
LIGHT DETECTOR USING NAND GATE
 
LDR (LIGHT DEPENDENT RESISTOR)
LDR (LIGHT DEPENDENT RESISTOR)LDR (LIGHT DEPENDENT RESISTOR)
LDR (LIGHT DEPENDENT RESISTOR)
 
Sensitive intrucer alaram
Sensitive intrucer alaramSensitive intrucer alaram
Sensitive intrucer alaram
 
70 interesting circuits
70 interesting circuits70 interesting circuits
70 interesting circuits
 
ir sensor.docx
ir sensor.docxir sensor.docx
ir sensor.docx
 
lab_2.pdf
lab_2.pdflab_2.pdf
lab_2.pdf
 

More from Wingston

OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012Wingston
 
05 content providers - Android
05   content providers - Android05   content providers - Android
05 content providers - AndroidWingston
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - AndroidWingston
 
03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - AndroidWingston
 
02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - AndroidWingston
 
01 introduction & setup - Android
01   introduction & setup - Android01   introduction & setup - Android
01 introduction & setup - AndroidWingston
 
OpenCV with android
OpenCV with androidOpenCV with android
OpenCV with androidWingston
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDLWingston
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - PointersWingston
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01Wingston
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introductionWingston
 
Embedded linux
Embedded linuxEmbedded linux
Embedded linuxWingston
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the ArduinoWingston
 
4.content mgmt
4.content mgmt4.content mgmt
4.content mgmtWingston
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for DrupalWingston
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in DrupalWingston
 
6 Special Howtos for Drupal
6 Special Howtos for Drupal6 Special Howtos for Drupal
6 Special Howtos for DrupalWingston
 
5 User Mgmt in Drupal
5 User Mgmt in Drupal5 User Mgmt in Drupal
5 User Mgmt in DrupalWingston
 
3 Configuring Drupal
3 Configuring Drupal3 Configuring Drupal
3 Configuring DrupalWingston
 

More from Wingston (20)

OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012OpenCV @ Droidcon 2012
OpenCV @ Droidcon 2012
 
05 content providers - Android
05   content providers - Android05   content providers - Android
05 content providers - Android
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
03 layouts & ui design - Android
03   layouts & ui design - Android03   layouts & ui design - Android
03 layouts & ui design - Android
 
02 hello world - Android
02   hello world - Android02   hello world - Android
02 hello world - Android
 
01 introduction & setup - Android
01   introduction & setup - Android01   introduction & setup - Android
01 introduction & setup - Android
 
OpenCV with android
OpenCV with androidOpenCV with android
OpenCV with android
 
C game programming - SDL
C game programming - SDLC game programming - SDL
C game programming - SDL
 
C programming - Pointers
C programming - PointersC programming - Pointers
C programming - Pointers
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introduction
 
Embedded linux
Embedded linuxEmbedded linux
Embedded linux
 
Introduction to the Arduino
Introduction to the ArduinoIntroduction to the Arduino
Introduction to the Arduino
 
4.content mgmt
4.content mgmt4.content mgmt
4.content mgmt
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for Drupal
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
 
6 Special Howtos for Drupal
6 Special Howtos for Drupal6 Special Howtos for Drupal
6 Special Howtos for Drupal
 
5 User Mgmt in Drupal
5 User Mgmt in Drupal5 User Mgmt in Drupal
5 User Mgmt in Drupal
 
3 Configuring Drupal
3 Configuring Drupal3 Configuring Drupal
3 Configuring Drupal
 

Recently uploaded

M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.Aaiza Hassan
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdfRenandantas16
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear RegressionRavindra Nath Shukla
 
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 
GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in managementchhavia330
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Roomdivyansh0kumar0
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsApsara Of India
 
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdfOrient Homes
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Tina Ji
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurSuhani Kapoor
 
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...lizamodels9
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...lizamodels9
 
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts ServiceVip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Serviceankitnayak356677
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechNewman George Leech
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Serviceritikaroy0888
 
The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024christinemoorman
 

Recently uploaded (20)

Forklift Operations: Safety through Cartoons
Forklift Operations: Safety through CartoonsForklift Operations: Safety through Cartoons
Forklift Operations: Safety through Cartoons
 
M.C Lodges -- Guest House in Jhang.
M.C Lodges --  Guest House in Jhang.M.C Lodges --  Guest House in Jhang.
M.C Lodges -- Guest House in Jhang.
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
 
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Old Faridabad ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 
GD Birla and his contribution in management
GD Birla and his contribution in managementGD Birla and his contribution in management
GD Birla and his contribution in management
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
 
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call GirlsCash Payment 9602870969 Escort Service in Udaipur Call Girls
Cash Payment 9602870969 Escort Service in Udaipur Call Girls
 
KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)
 
Catalogue ONG NUOC PPR DE NHAT .pdf
Catalogue ONG NUOC PPR DE NHAT      .pdfCatalogue ONG NUOC PPR DE NHAT      .pdf
Catalogue ONG NUOC PPR DE NHAT .pdf
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
Russian Faridabad Call Girls(Badarpur) : ☎ 8168257667, @4999
 
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service JamshedpurVIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
VIP Call Girl Jamshedpur Aashi 8250192130 Independent Escort Service Jamshedpur
 
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
Call Girls In Connaught Place Delhi ❤️88604**77959_Russian 100% Genuine Escor...
 
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
 
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts ServiceVip Female Escorts Noida 9711199171 Greater Noida Escorts Service
Vip Female Escorts Noida 9711199171 Greater Noida Escorts Service
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 
RE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman LeechRE Capital's Visionary Leadership under Newman Leech
RE Capital's Visionary Leadership under Newman Leech
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024The CMO Survey - Highlights and Insights Report - Spring 2024
The CMO Survey - Highlights and Insights Report - Spring 2024
 

04 Arduino Peripheral Interfacing

  • 1.
  • 2. Temperature sensors 0 Gives a Vout propotional to ambient room temperature. 0 Concept : as temperature increases, voltage across a p-n junction increases at a known rate. (in this case Vbe) 0 Voltage at Anlg.Pin in Volts = (reading from ADC) * (5/1024) V 0 Centigrade temperature = [(analog voltage in V) – 0.5] * 100
  • 3. Before: Writing the code 0 Review: 0 How does the lm35 work? 0 Read datasheet of lm35. 0 How to connect it to arduino? 0 What reference to use? 0 What sort of noises will be present? 0 What does the analogue input signify?
  • 6. Temp sensor code 0 Connect lm35 as per circuit diagram in 7. Temp Sensor folder. 0 We’re giving AREF as 3.3V to reduce noise from the LM35 and give more accurate readings. 0 Upload code onto Arduino and Output is seen in the Serial monitor of the Arduino.
  • 7. Write the code 1. Decide which analogue pin you’re going to and assign it to a global variable 2. in setup() { }, initialize serial port to 9600 baud rate to send temp reading out to PC. 3. In loop() { }, take the analogue reading from a pin and store it in a temp float variable. 4. Multiply reading by 5.0 and then divide by 1024 to get voltage value read by the port. Store this is a float variable called volt. 5. Print out this value to the serial port and check.
  • 8. Keep Writing the code 0 To get temp in centigrade, (volt – 0.5) * 100 0 This is the ambient temperature recognized by the LM35 in Celsius. 0 Send it to the serial port and check your code. 0 To convert to fahrenheight, mult by 9 then divide by 5 then add 32 to that result. Send it to serial port too. 0 Congratulate yourself please.
  • 9. Improvements? 0 Use 3.3V as reference to increase resolution since datasheet says that resolution of lm35 ~ 10mV. 0 Put in on PCB to avoid noise by breadboard internal resistance, 0 DO NOT LIGHT THE LM35 OR IMMERSE IT IN WATER. 0 Make a waterproof casing for the lm35 to test temp of liquids. 0 Any other applications?
  • 10. LDR 0 An LDR is a Light Dependent Resistor. 0 As in the resistance offered by this device to an electrical circuit is dependent on the amount of light falling on the circuit. 0 Also called photocells because they convert light energy to an electrical response. 0 Useful for on-when-light/off-when-dark.
  • 11.
  • 12. How to connect the LDR 0 LDR is basically a resistor, so it can be connected anyway. 0 You need a pull-down resistor to avoid sinking all the current onto the arduino pin. 0 Circuit is GND-10kohn-LDR-VCC. 0 This circuit will only work if between 0-5V. If light is too bright, it will saturate at 5V. 0 putting a variable resistor in place of 10k allows for controlling saturation with too bright/too dark light.
  • 13. Photocell Current Ambient Ambient LDR + R Voltage resistance thru LDR light like… light (lux) (Ω) across R (Ω) +R Dim 0.1 lux 600KΩ 610 KΩ 0.008 mA 0.1 V hallway Moonlit 1 lux 70 KΩ 80 KΩ 0.07 mA 0.6 V night Room 10 lux 10 KΩ 20 KΩ 0.25 mA 2.5 V Dark overcast day / 100 lux 1.5 KΩ 11.5 KΩ 0.43 mA 4.3 V Bright room Overcast 1000 lux 300 Ω 10.03 KΩ 0.5 mA 5V day
  • 14.
  • 15. Writing code! 0 decide analoge pin used as input to LDR. 0 In setup(){ }, initialize serial port with 9600. 0 In loop(){ }, first do an analogueread(pin) and store it in an int variable called reading. 0 This value represents illumination received by LDR. 0 Send it to Serial Port. 0 Allow delay of some time to let the ADC settle.
  • 16. Application 1 0 Make thresholds and determine the brightness received and send it via serial port. if (reading < 10) { Serial.println(" - Dark"); } else if (reading < 200) { Serial.println(" - Dim"); } else if (reading < 500) { Serial.println(" - Light"); } else if (reading < 800) { Serial.println(" - Bright"); } else { Serial.println(" - Very bright"); }
  • 17. Application 2 0 Take the analogue reading and use it as the delay amount in an LED blinking scenario. Use ledpin = 13. void loop() { val = analogRead(LDR); digitalWrite(ledPin, HIGH); delay(val); digitalWrite(ledPin, LOW); delay(val); }
  • 18. Another Application 0 Put three LEDs around the LDR. Red, Green and Blue. 0 Put an object of a particular color in front of the LDR. 0 Light up RED LED and measure LDR value 0 Light up GREEN LED and measure LDR value 0 Light up BLUE LED and measure LDR value 0 From these three analogue values you can determine the color of object being sensed.
  • 19. Sensor Data on PC 0 Reading and plotting sensor data on PC is very simple on the arduino. 0 Send data continuously to the computer over the serial port. 0 Data can be viewed by any program capable of viewing this data
  • 20. Send sensor data to serial port 0 Open the folder Sensor data graph 0 Upload the arduino code onto the arduino and close arduino IDE after checking serial monitor. 0 In softwares folder extract the processing folder. 0 Open processing and copy the processing code onto it and run. 0 Make sure serial port number in the processing sketch matches arduino
  • 21. The motor shield The motor shield goes on top 1. DC Motor Interface of the arduino neatly. Drives 2 motors with L293D DC Motor Driver IC. There are loads of shields for the arduino that provide 2. IR paired sensors different functionality. For line sensing, 4 IR sensor pairs can be attached and controlled. Be careful removing the shield, if you bend the pins, 3. The Buzzer or Servo Motor you cant put the shield in Selectable via jumper again. 4. The Switch or Servo Motor Selectable via jumper 5. Two LEDs
  • 22.
  • 23.
  • 24. IR TX RX Pair 0 An IR transmitter (TX) is a LED that emits light in the infrared spectrum. 0 (most cameras see IR, light up the IR LED and point a camera at it to check) 0 An IR Receiver (RX) is a transistor with the base exposed. 0 The base voltage depends on the amount of IR received and it controls the amount of current passing through the C-E junction (leads).
  • 25. IR schematic 0 The IR TX LED is connected through a current limiting resisto 0 The IR RX is connected via a variable potentiometer to a voltage comparator to give a digital output. 0 The pot is used to adjust For ambient light intensity.
  • 26. Remember 0 The IR TX RX pairs should be spaced 1/4th of an inch apart for optimal detection. 0 Calibration of IR sensors is important to adjust the sensors for ambient light. 0 The output of this circuit is DIGITAL and read by a digital pin. 1 – obstruction; 0 – No obstruction. 0 If you have to use IR sensors in the sun, use electrical tape to provide adequate shielding.
  • 27. Using the IR sensors 0 The motor shield has 4 IR sensors and 4 pots. 0 Connect the IR dongles to the placeholders. They go in only one way 0 There are status LEDs just next to each IR socket, if the comparator goes HIGH, the LED lights. This is for calibration. 0 Keep the IR sensor pointed at nothing (no obstruction). 0 Use a screwdriver and GENTLY turn the appropriate POT until the respective IR sensors status LED turns dark. 0 Check with your hand if LED lights, if not readjust as you like.
  • 28. PINS 0 The table below shows the pin arrangement for the 4 sensors on the shield. 0 If the shield is mounted, then these 4 pins provide the output of the comparator. 0 Use digitalread(pin) to see the state of the pin at any time.
  • 29. Try 0 Connect all four IR sensors and calibrate them. 0 Write a program to output which of the 4 IR sensors has gone HIGH to the serial port. 0 CHALLENGE: Try and make sure that the message on the serial port doesn’t repeat until the IR sensor has gone LOW again (obstruction removed). It shouldn't continuously output the message if the IR sensor is obstructed,
  • 30. DC motors 0 Motors are devices that convert electrical energy to mechanical energy. 0 Motors come in different varieties: AC, DC, Servo, Stepper etc 0 If motor draws less than 40mA of current, it can be directlu wired to an arduino pin. 0 Current drawn by a DC motor is propotional to speed and torque. To avoid burning out the arduino, we use motor drivers to control DC motors.
  • 31. The L293 driver 0 This chip isolates logic level voltages and the motor supply voltages. 0 It as also called a H-bridge. 0 It uses the transistors as a switch concept to electrically switch a DC power supply onto the terminals of the motor. 0 The driver can control two motors independently from the same supply.
  • 33. The Motor Shield 0 The motor driver is present on the shield which also contains a wire block for easy connection of the wires. 0 The supply will have terminals marked on the board. Do not reverse - these connections. + 0 Motor can be connected in anyway. The direction might have to be calibrated by testing if the terminals are reversed.
  • 34. Arduino shield to Motor Driver Pinout 0 To use a motor, set the enable pin to high in the setup() { } 0 Motor movement is done in loop() { } 0 If l1 is HIGH and l2 is LOW, motor turn in one direction. 0 If l1 is LOW and l2 is HIGH, the motor turns in the other direction. 0 If both l1 and l2 are set to HIGH or LOW, then motor is stopped.
  • 35. Wiring motors 0 Attach the arduino shield onto the arduino. 0 Take a 9V battery cap and screw it onto the motor supply terminals. Take care of polarity. 0 Red >> + and Black >> - 0 Wire up the motors and connect them to the terminals.
  • 36. TRY 0 Move both motors in same direction. 0 Reverse both motors. 0 Stop one and turn the other. 0 Stop the other and turn the one. 0 Make each motor turn in a different direction.
  • 37. Exercise 0 Combine the functionality of 2 IR sensors and the motors to make an obstacle avoider bot. 0 Algorith: 0 Move forward, left and right randomly. 0 If IR sensors detect an obstruction, move a little back in the opposite side of the obstruction 0 Continue.