Arduino Robotics Workshop
          Day 1
          Sudar Muthu (@sudarmuthu)
   http://hardwarefun.com/arduino-workshop
             http://github.com/sudar
Who am I?


           Research Engineer by profession
           Build’s robots as a hobby
           Playing with Arduino for more than 3 years
           Blog about Arduino at http://hardwarefun.com
           Moderator for Arduino India forum




http://hardwarefun.com             2
Special Thanks


                         Anil and Sysplay




http://hardwarefun.com             3
Objective


           Introduce Arduino
           Learn about robotics
           Learn about sensors
           Build a small bot
           Make it autonomous
           Fully hands on
           Details at http://hardwarefun.com/arduino-workshop

http://hardwarefun.com             4
Basics of Robotics




http://hardwarefun.com           5
Anatomy of a Robot




Sensors

                      Motors
          Processor
Sensors (Input)
Motors (Output)
Processor (Brain)
Getting to know your Robotics
                      Kit



http://hardwarefun.com   10
Can you identify the different
             components in the kit?



http://hardwarefun.com   11
Breadboard Basics




http://hardwarefun.com           12
How to use a breadboard


           The first two and the last two rows are connected
           In all the other rows, columns are connected
           Connect the first and last row to power
           Connect the second and second last row to ground




http://hardwarefun.com             13
Arduino




http://hardwarefun.com      14
Different Arduino types


           Arduino Uno (The one used for this workshop)
           Arduino Mega
           Arduino Due
           Lillypad
           Arduino BT
           Arduino Ethernet
           .. and clones

http://hardwarefun.com             15
Getting to know your Arduino




http://hardwarefun.com   16
Identify these components in
                         Arduino


           Microcontroller
           Power jacket
           USB jacket
           Digital pins
           Analog pins
           Reset button



http://hardwarefun.com       17
Identify these components in
                         Arduino


           Voltage Regulator
           Power Pins (how many are there?)
           Ground Pins (how many are there?)
           Vin Pin
           Rx and Tx Pins
           ICSP Headers



http://hardwarefun.com            18
Identify these components in
                         Arduino


           Power Led
           Rx and Tx Led’s
           Test Led
           Crystal
           Anything else?




http://hardwarefun.com       19
Powering up Arduino




http://hardwarefun.com        20
Different ways to power up Arduino


           Using USB cable
           Using DC power jacket
           Giving voltage directly into Vin pin
           Giving regulated voltage directly into 5V pin




http://hardwarefun.com               21
Setting up Arduino




http://hardwarefun.com           22
Testing the setup with a “Hello
               World” program



http://hardwarefun.com   23
Blinking LED




http://hardwarefun.com        24
Making a LED blink


           Insert a LED in pin 13
           Open File->Examples->Basics->Blink
           Select Tools->Boards->Arduino Uno
           Select File->Upload (or press ctrl+u)
           You should get the message “Done upload”
           Your Led should blink
           Congrats you can program Arduino now 

http://hardwarefun.com            25
Anatomy of an Arduino sketch




http://hardwarefun.com   26
Printing values through Serial


           Uno has one UART hardware port, using which we
           can exchange information with computer
           Very useful for debugging
           Works at a specified baud rate
           Use Serial Monitor to read values
           SoftwareSerial is also available



http://hardwarefun.com            27
Digital Input and output




http://hardwarefun.com      28
Digital Input




http://hardwarefun.com         29
Digital Output


        The LED blink that we did at “setting up Arduino” is
        Digital output




http://hardwarefun.com             30
Analog Input




http://hardwarefun.com        31
Reading Analog values from sensors


           Connect the LDR on pin A0 and Gnd
           LDR’s resistance varies based on the amount of light
           present
           Read the current value using analogRead()
           Print the value in Serial Monitor




http://hardwarefun.com              32
Control an LED based on light


void setup()
{
  pinMode(13, OUTPUT);
}

void loop()
{
  int val = analogRead(A0);
  if (val > 50) {
      digitalWrite(13, HIGH);
  } else {
      digitalWrite(13, LOW);
  }
}
Analog Output




http://hardwarefun.com         34
Analog Output


           What is PWM?
           Analog like behavior using digital output
           Works by switching the LED on and off regularly
           Changing the brightness of a Led




http://hardwarefun.com             35
Introduction to Batteries




http://hardwarefun.com      36
Main Concepts


           What is voltage?
           What is current ratting?
           Rechargeable
           Don’t ever short circuit it




http://hardwarefun.com                   37
Different types of batteries




http://hardwarefun.com    38
Can you identify the battery
              which is part of the kit?



http://hardwarefun.com   39
Let’s get some Food




http://hardwarefun.com            40
Introduction to Motors




http://hardwarefun.com       41
Dc Motor vs stepper motor




http://hardwarefun.com   42
Identify the motor in the kit




http://hardwarefun.com    43
H-Bridge




http://hardwarefun.com      44
Understanding the pins of H-
                    Bridge



http://hardwarefun.com   45
Connecting motors to H-Bridge




http://hardwarefun.com   46
Let’s assemble the bot
Teaching robot to crawl


Move Forward
    Both motors rotate in the forward direction

Move Backward
    Both motors rotate in the reverse direction

Turn left
     Left motor stops. Only right motor rotates forward

Turn Right
     Left motor moves forward. Right motor stops
Putting everything together

You have your first fully autonomous
           robot ready.

     Now take her for a walk 
What we will see tomorrow


           Varying the speed of the motor
           How IR works
           Making use of IR to find obstacles
           Make the bot avoid strangers
           Making it autonomous
           Future ideas



http://hardwarefun.com              50
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
 Workshop Details http://hardwarefun.com/arduino-
  workshop
Questions
          Thank You

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

Arduino Robotics workshop Day1