Arduino Robotics workshop day2

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

description

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

Transcript of Arduino Robotics workshop day2

Page 1: Arduino Robotics workshop day2

Arduino Robotics Workshop

Day 2Sudar Muthu (@sudarmuthu)

http://hardwarefun.com/arduino-workshophttp://github.com/sudar

Page 2: Arduino Robotics workshop day2

2

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

What we have seen so far?

http://hardwarefun.com

Page 3: Arduino Robotics workshop day2

http://hardwarefun.com 3

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

Today we will see..

Page 4: Arduino Robotics workshop day2

http://hardwarefun.com 4

Varying the speed of the motor using PWM

Page 5: Arduino Robotics workshop day2

http://hardwarefun.com 5

Playing tones in the buzzer

Page 6: Arduino Robotics workshop day2

http://hardwarefun.com 6

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

Usage:

tone(pin, frequency, duration)

Playing sound

Page 7: Arduino Robotics workshop day2

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

Page 8: Arduino Robotics workshop day2

http://hardwarefun.com 8

Let’s see some code

Page 9: Arduino Robotics workshop day2

http://hardwarefun.com 9

Let’s get some food

Page 10: Arduino Robotics workshop day2

http://hardwarefun.com 10

What are the limitations that we have faced so far?

Page 11: Arduino Robotics workshop day2

http://hardwarefun.com 11

Using Delay

Page 12: Arduino Robotics workshop day2

http://hardwarefun.com 12

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

Issues with delay

Page 13: Arduino Robotics workshop day2

http://hardwarefun.com 13

How to fix it?

Page 14: Arduino Robotics workshop day2

http://hardwarefun.com 14

Using Timer libraryhttps://github.com/JChristensen/Timer

Page 15: Arduino Robotics workshop day2

http://hardwarefun.com 15

If we don’t read the pin, then we miss the value

Page 16: Arduino Robotics workshop day2

http://hardwarefun.com 16

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

startingValue); pulse(int pin, long period, int startingValue); update();

Methods in Timer library

Page 17: Arduino Robotics workshop day2

http://hardwarefun.com 17

Interrupts

Page 18: Arduino Robotics workshop day2

http://hardwarefun.com 18

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

Hardware support

Page 19: Arduino Robotics workshop day2

http://hardwarefun.com 19

Let’s see some code

Page 20: Arduino Robotics workshop day2

http://hardwarefun.com 20

What if we need it on other pins?

Page 21: Arduino Robotics workshop day2

http://hardwarefun.com 21

Software Interruptshttp://code.google.com/p/arduino-pinchangeint/

Page 22: Arduino Robotics workshop day2

http://hardwarefun.com 22

Can be used on any pin

Page 23: Arduino Robotics workshop day2

http://hardwarefun.com 23

Let’s see some code

Page 24: Arduino Robotics workshop day2

http://hardwarefun.com 24

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

Some ideas to try

Page 25: Arduino Robotics workshop day2

http://hardwarefun.com 25

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

Things I have tried

Page 26: Arduino Robotics workshop day2

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

Page 27: Arduino Robotics workshop day2

Questions

Thank You

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

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