arduino robotics workshop day1

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

Upload: sudar-muthu

Post on 28-Jan-2015

134 views

Category:

Technology


7 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Arduino Robotics workshop Day1

Arduino Robotics WorkshopDay 1

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

http://github.com/sudar

Page 2: Arduino Robotics workshop Day1

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

Page 3: Arduino Robotics workshop Day1

http://hardwarefun.com 3

Anil and SysplaySpecial Thanks

Page 4: Arduino Robotics workshop Day1

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

Page 5: Arduino Robotics workshop Day1

http://hardwarefun.com 5

Basics of Robotics

Page 6: Arduino Robotics workshop Day1

Motors

Sensors

Processor

Anatomy of a Robot

Page 7: Arduino Robotics workshop Day1

Sensors (Input)

Page 8: Arduino Robotics workshop Day1

Motors (Output)

Page 9: Arduino Robotics workshop Day1

Processor (Brain)

Page 10: Arduino Robotics workshop Day1

http://hardwarefun.com 10

Getting to know your Robotics Kit

Page 11: Arduino Robotics workshop Day1

http://hardwarefun.com 11

Can you identify the different components in

the kit?

Page 12: Arduino Robotics workshop Day1

http://hardwarefun.com 12

Breadboard Basics

Page 13: Arduino Robotics workshop Day1

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

Page 14: Arduino Robotics workshop Day1

http://hardwarefun.com 14

Arduino

Page 15: Arduino Robotics workshop Day1

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

Page 16: Arduino Robotics workshop Day1

http://hardwarefun.com 16

Getting to know your Arduino

Page 17: Arduino Robotics workshop Day1

http://hardwarefun.com 17

Microcontroller Power jacket USB jacket Digital pins Analog pins Reset button

Identify these components in Arduino

Page 18: Arduino Robotics workshop Day1

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

Page 19: Arduino Robotics workshop Day1

http://hardwarefun.com 19

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

Identify these components in Arduino

Page 20: Arduino Robotics workshop Day1

http://hardwarefun.com 20

Powering up Arduino

Page 21: Arduino Robotics workshop Day1

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

Page 22: Arduino Robotics workshop Day1

http://hardwarefun.com 22

Setting up Arduino

Page 23: Arduino Robotics workshop Day1

http://hardwarefun.com 23

Testing the setup with a “Hello World” program

Page 24: Arduino Robotics workshop Day1

http://hardwarefun.com 24

Blinking LED

Page 25: Arduino Robotics workshop Day1

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

Page 26: Arduino Robotics workshop Day1

http://hardwarefun.com 26

Anatomy of an Arduino sketch

Page 27: Arduino Robotics workshop Day1

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

Page 28: Arduino Robotics workshop Day1

http://hardwarefun.com 28

Digital Input and output

Page 29: Arduino Robotics workshop Day1

http://hardwarefun.com 29

Digital Input

Page 30: Arduino Robotics workshop Day1

http://hardwarefun.com 30

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

Digital Output

Page 31: Arduino Robotics workshop Day1

http://hardwarefun.com 31

Analog Input

Page 32: Arduino Robotics workshop Day1

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

Page 33: Arduino Robotics workshop Day1

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

Page 34: Arduino Robotics workshop Day1

http://hardwarefun.com 34

Analog Output

Page 35: Arduino Robotics workshop Day1

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

Page 36: Arduino Robotics workshop Day1

http://hardwarefun.com 36

Introduction to Batteries

Page 37: Arduino Robotics workshop Day1

http://hardwarefun.com 37

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

Main Concepts

Page 38: Arduino Robotics workshop Day1

http://hardwarefun.com 38

Different types of batteries

Page 39: Arduino Robotics workshop Day1

http://hardwarefun.com 39

Can you identify the battery which is part of

the kit?

Page 40: Arduino Robotics workshop Day1

http://hardwarefun.com 40

Let’s get some Food

Page 41: Arduino Robotics workshop Day1

http://hardwarefun.com 41

Introduction to Motors

Page 42: Arduino Robotics workshop Day1

http://hardwarefun.com 42

Dc Motor vs stepper motor

Page 43: Arduino Robotics workshop Day1

http://hardwarefun.com 43

Identify the motor in the kit

Page 44: Arduino Robotics workshop Day1

http://hardwarefun.com 44

H-Bridge

Page 45: Arduino Robotics workshop Day1

http://hardwarefun.com 45

Understanding the pins of H-Bridge

Page 46: Arduino Robotics workshop Day1

http://hardwarefun.com 46

Connecting motors to H-Bridge

Page 47: Arduino Robotics workshop Day1

Let’s assemble the bot

Page 48: Arduino Robotics workshop Day1

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

Page 49: Arduino Robotics workshop Day1

Putting everything together

You have your first fully autonomous robot ready.

Now take her for a walk

Page 50: Arduino Robotics workshop Day1

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

Page 51: Arduino Robotics workshop Day1

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

Page 52: Arduino Robotics workshop Day1

Questions

Thank You

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

https://github.com/sudar/arduino-robotics-workshop