Arduino Robotics workshop Day1

Post on 28-Jan-2015

124 views 7 download

Tags:

description

Slides from my Arduino robotic workshop http://hardwarefun.com/arduino-workshop

transcript

Arduino Robotics WorkshopDay 1

Sudar Muthu (@sudarmuthu)http://hardwarefun.com/arduino-workshop

http://github.com/sudar

2

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

Who am I?

http://hardwarefun.com

http://hardwarefun.com 3

Anil and SysplaySpecial Thanks

http://hardwarefun.com 4

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

Objective

http://hardwarefun.com 5

Basics of Robotics

Motors

Sensors

Processor

Anatomy of a Robot

Sensors (Input)

Motors (Output)

Processor (Brain)

http://hardwarefun.com 10

Getting to know your Robotics Kit

http://hardwarefun.com 11

Can you identify the different components in

the kit?

http://hardwarefun.com 12

Breadboard Basics

http://hardwarefun.com 13

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

How to use a breadboard

http://hardwarefun.com 14

Arduino

http://hardwarefun.com 15

Arduino Uno (The one used for this workshop)

Arduino Mega Arduino Due Lillypad Arduino BT Arduino Ethernet .. and clones

Different Arduino types

http://hardwarefun.com 16

Getting to know your Arduino

http://hardwarefun.com 17

Microcontroller Power jacket USB jacket Digital pins Analog pins Reset button

Identify these components in Arduino

http://hardwarefun.com 18

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

Identify these components in Arduino

http://hardwarefun.com 19

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

Identify these components in Arduino

http://hardwarefun.com 20

Powering up Arduino

http://hardwarefun.com 21

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

Different ways to power up Arduino

http://hardwarefun.com 22

Setting up Arduino

http://hardwarefun.com 23

Testing the setup with a “Hello World” program

http://hardwarefun.com 24

Blinking LED

http://hardwarefun.com 25

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

Making a LED blink

http://hardwarefun.com 26

Anatomy of an Arduino sketch

http://hardwarefun.com 27

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

Printing values through Serial

http://hardwarefun.com 28

Digital Input and output

http://hardwarefun.com 29

Digital Input

http://hardwarefun.com 30

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

Digital Output

http://hardwarefun.com 31

Analog Input

http://hardwarefun.com 32

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

Reading Analog values from sensors

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); }}

http://hardwarefun.com 34

Analog Output

http://hardwarefun.com 35

What is PWM? Analog like behavior using digital output Works by switching the LED on and off

regularly Changing the brightness of a Led

Analog Output

http://hardwarefun.com 36

Introduction to Batteries

http://hardwarefun.com 37

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

Main Concepts

http://hardwarefun.com 38

Different types of batteries

http://hardwarefun.com 39

Can you identify the battery which is part of

the kit?

http://hardwarefun.com 40

Let’s get some Food

http://hardwarefun.com 41

Introduction to Motors

http://hardwarefun.com 42

Dc Motor vs stepper motor

http://hardwarefun.com 43

Identify the motor in the kit

http://hardwarefun.com 44

H-Bridge

http://hardwarefun.com 45

Understanding the pins of H-Bridge

http://hardwarefun.com 46

Connecting motors to H-Bridge

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

http://hardwarefun.com 50

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

What we will see tomorrow

Links

Arduino – http://arduino.ccAsimi – A simple bot using Arduino

http://hardwarefun.com/project/asimiGetting 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