KEMBAR78
Arduino Robotics workshop day2 | PPTX
Arduino Robotics Workshop
          Day 2
          Sudar Muthu (@sudarmuthu)
   http://hardwarefun.com/arduino-workshop
             http://github.com/sudar
What we have seen so far?


           Basics of Robotics
           Using Breadboard
           Digital and Analog I/P and O/P
           Serial Communication
           Controlling DC Motors
           Assembled the robot
           Made it run

http://hardwarefun.com              2
Today we will see..


           Varying the speed of the motor
           Play some tunes using the buzzer
           How IR works
           Making use of IR to find obstacles
           Make the bot avoid strangers
           Making it autonomous
           Some Advanced stuff

http://hardwarefun.com              3
Varying the speed of the motor
                 using PWM



http://hardwarefun.com   4
Playing tones in the buzzer




http://hardwarefun.com    5
Playing sound


        We can generate a square wave at specified frequency
        using tone() function

        Usage:

        tone(pin, frequency, duration)



http://hardwarefun.com             6
Teaching robot to avoid strangers


  Two IR LED’s. One receiver, one transmitter
  Both face the same direction
  Keep transmitting IR waves
  If receiver receives waves, then there is a obstacle
  Otherwise keep moving
Let’s see some code




http://hardwarefun.com            8
Let’s get some food 




http://hardwarefun.com        9
What are the limitations that
             we have faced so far?



http://hardwarefun.com   10
Using Delay




http://hardwarefun.com        11
Issues with delay


           Your microcontroller is going to sleep
           You can’t read or write while in delay
           Eg: You can’t detect an obstacle when the bot is
           making a turn




http://hardwarefun.com              12
How to fix it?




http://hardwarefun.com         13
Using Timer library
                         https://github.com/JChristensen/Timer




http://hardwarefun.com                    14
If we don’t read the pin, then
                we miss the value



http://hardwarefun.com   15
Methods in Timer library


           every(long period, callback);
           after(long duration, callback);
           oscillate(int pin, long period, int startingValue);
           pulse(int pin, long period, int startingValue);
           update();




http://hardwarefun.com                16
Interrupts




http://hardwarefun.com       17
Hardware support


           Pin 2 and 3
           Supports LOW, CHANGE, RISING, FALLING
           No software support is needed
           Can be removed as well




http://hardwarefun.com           18
Let’s see some code




http://hardwarefun.com            19
What if we need it on other
                        pins?



http://hardwarefun.com    20
Software Interrupts
                         http://code.google.com/p/arduino-pinchangeint/




http://hardwarefun.com                         21
Can be used on any pin




http://hardwarefun.com       22
Let’s see some code




http://hardwarefun.com            23
Some ideas to try


           Making your robot follow a line
           Making your robot stay in a table
           Replace IR with ultrasound sensor
           Control the bot remotely using RF




http://hardwarefun.com             24
Things I have tried


           Controlled it using Android phone
           Controlled it using JavaScript and WebSockets
           Controlled it using Bluetooth
           Controlled it using RF
           Added a missile launcher to it

                           https://github.com/sudar

http://hardwarefun.com                25
Links

 Arduino – http://arduino.cc
 Asimi – A simple bot using Arduino
  http://hardwarefun.com/project/asimi
 Getting started with hardware programming
  http://hardwarefun.com/tutorials/getting-started-with-
  hardware-programming
 Getting started with Arduino
  http://hardwarefun.com/tutorials/getting-started-with-
  arduino-and-avr
Questions
          Thank You

            Sudar Muthu (@sudarmuthu)
    http://hardwarefun.com/arduino-workshop
https://github.com/sudar/arduino-robotics-workshop

Arduino Robotics workshop day2

  • 1.
    Arduino Robotics Workshop Day 2 Sudar Muthu (@sudarmuthu) http://hardwarefun.com/arduino-workshop http://github.com/sudar
  • 2.
    What we haveseen so far? Basics of Robotics Using Breadboard Digital and Analog I/P and O/P Serial Communication Controlling DC Motors Assembled the robot Made it run http://hardwarefun.com 2
  • 3.
    Today we willsee.. Varying the speed of the motor Play some tunes using the buzzer How IR works Making use of IR to find obstacles Make the bot avoid strangers Making it autonomous Some Advanced stuff http://hardwarefun.com 3
  • 4.
    Varying the speedof the motor using PWM http://hardwarefun.com 4
  • 5.
    Playing tones inthe buzzer http://hardwarefun.com 5
  • 6.
    Playing sound We can generate a square wave at specified frequency using tone() function Usage: tone(pin, frequency, duration) http://hardwarefun.com 6
  • 7.
    Teaching robot toavoid strangers Two IR LED’s. One receiver, one transmitter Both face the same direction Keep transmitting IR waves If receiver receives waves, then there is a obstacle Otherwise keep moving
  • 8.
    Let’s see somecode http://hardwarefun.com 8
  • 9.
    Let’s get somefood  http://hardwarefun.com 9
  • 10.
    What are thelimitations that we have faced so far? http://hardwarefun.com 10
  • 11.
  • 12.
    Issues with delay Your microcontroller is going to sleep You can’t read or write while in delay Eg: You can’t detect an obstacle when the bot is making a turn http://hardwarefun.com 12
  • 13.
    How to fixit? http://hardwarefun.com 13
  • 14.
    Using Timer library https://github.com/JChristensen/Timer http://hardwarefun.com 14
  • 15.
    If we don’tread the pin, then we miss the value http://hardwarefun.com 15
  • 16.
    Methods in Timerlibrary every(long period, callback); after(long duration, callback); oscillate(int pin, long period, int startingValue); pulse(int pin, long period, int startingValue); update(); http://hardwarefun.com 16
  • 17.
  • 18.
    Hardware support Pin 2 and 3 Supports LOW, CHANGE, RISING, FALLING No software support is needed Can be removed as well http://hardwarefun.com 18
  • 19.
    Let’s see somecode http://hardwarefun.com 19
  • 20.
    What if weneed it on other pins? http://hardwarefun.com 20
  • 21.
    Software Interrupts http://code.google.com/p/arduino-pinchangeint/ http://hardwarefun.com 21
  • 22.
    Can be usedon any pin http://hardwarefun.com 22
  • 23.
    Let’s see somecode http://hardwarefun.com 23
  • 24.
    Some ideas totry Making your robot follow a line Making your robot stay in a table Replace IR with ultrasound sensor Control the bot remotely using RF http://hardwarefun.com 24
  • 25.
    Things I havetried Controlled it using Android phone Controlled it using JavaScript and WebSockets Controlled it using Bluetooth Controlled it using RF Added a missile launcher to it https://github.com/sudar http://hardwarefun.com 25
  • 26.
    Links  Arduino –http://arduino.cc  Asimi – A simple bot using Arduino http://hardwarefun.com/project/asimi  Getting started with hardware programming http://hardwarefun.com/tutorials/getting-started-with- hardware-programming  Getting started with Arduino http://hardwarefun.com/tutorials/getting-started-with- arduino-and-avr
  • 27.
    Questions Thank You Sudar Muthu (@sudarmuthu) http://hardwarefun.com/arduino-workshop https://github.com/sudar/arduino-robotics-workshop