makeweekend 2013 robotics - arduino and hardware introduction
DESCRIPTION
Arduino is a very good programming language widely use for casual robotics.TRANSCRIPT
![Page 1: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/1.jpg)
Makeweekend Robotics
![Page 2: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/2.jpg)
TANDEMIC
WE BUILD TECHNOLOGY TO MAKE THE WORLD A
BETTER PLACE
![Page 3: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/3.jpg)
THANKS
![Page 5: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/5.jpg)
The Challenges
1. The Water Drone Challenge2. The Awesomeness Challenge
But pick something...
• That you can build in 1-2 days
• Where you can get the necessary supplies over the weekend
![Page 6: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/6.jpg)
Water Drone Challenge
Launch into the waterFollow a course pathIn less than 10 minutes
Winners...Are fastestAutonomous, self-powered with the battery and
single motorDon't sink or explode, deviate from the course
![Page 7: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/7.jpg)
Awesomeness Challenge
Autonomous - instructions from Arduino board
Winners...Make us go wow!Must work during the demo session
![Page 8: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/8.jpg)
Prize for Speed Challenge (x5)
The 3pi robot is designed to excel in line-following and maze-solving competitions
![Page 9: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/9.jpg)
Prize for Awesomeness challenge (X5)
Zumo Bot - To compete in sumo bot competitions.
![Page 10: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/10.jpg)
Where you can find supplies
Outdoor hardware station - outsideAnything that is not electronicCutting and drilling stuff -- work bench outside
(wood, pipes, etc)
Food - outsideProgramming, soldering, electronics - at
your tables
![Page 11: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/11.jpg)
Recommended Process
Program & buildCheck with Sky / ChrisTest in kiddie pool
![Page 13: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/13.jpg)
The Agenda
• Arduino• Setup• IDE introduction• Arduino programming• Hardware setup• Useful things• Additional requirements• Further information
![Page 14: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/14.jpg)
Arduino
![Page 15: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/15.jpg)
Arduino
Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software.
![Page 16: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/16.jpg)
Setup
![Page 17: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/17.jpg)
Setup
• Install Arduino-IDEo Unzip arduino-1.0.4-windows.zip
• Insert the USB cable into the Arduino and your computer
• If the drivers are not automatically detected, you find them inside the extracted folder
• Open the Arduino.exe
![Page 18: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/18.jpg)
IDE Introduction
![Page 19: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/19.jpg)
Arduino IDE
Editor
BuildFlas
h
Error
![Page 20: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/20.jpg)
Configuration
![Page 21: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/21.jpg)
Configuration
![Page 22: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/22.jpg)
Load Basic example
![Page 23: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/23.jpg)
Arduino Programming
![Page 24: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/24.jpg)
Sketch
• A sketch is the name that Arduino uses for a program. It's the unit of code that is uploaded to and run on an Arduino board.
http://arduino.cc/en/Tutorial/Sketch
![Page 25: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/25.jpg)
Example
![Page 26: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/26.jpg)
C\C++ with Arduino
General:
• Statements are closed with a ;
• Curly brackets define a scope { }
http://arduino.cc/en/Tutorial/HomePage
![Page 27: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/27.jpg)
C\C++ with Arduino
Variables: Named place to store information of a specific type
• Different types: int, char, long, float,boolean
• Declare and define: int x;
• Store data on a variable: x=10;
• Use a variable:y=x+x;
http://www.arduino.cc/en/Reference/VariableDeclaration
![Page 28: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/28.jpg)
C\C++ with Arduino
![Page 29: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/29.jpg)
C\C++ with Arduino
Functions: Reusable/Recallable piece of code
• Functions define an own scope
• Declare and define:Name(Parametertype parametername, ...){
Functionbody}
• Call function:Name(variable or value to pass if any);
http://arduino.cc/en/Reference/FunctionDeclaration
![Page 30: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/30.jpg)
C\C++ with Arduino
![Page 31: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/31.jpg)
C\C++ with Arduino
Special functions:Setup:
The setup function is called once on power up of the Arduino. This is the place to initialize and setup your environment.
Loop:Loop is called endless in a "Loop" as long your device is powered. Here you place the program logic.
![Page 32: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/32.jpg)
C\C++ with Arduino
![Page 33: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/33.jpg)
C\C++ with Arduino
Objects: Objects combine functions and variables to an own stateful object, described by classes. The object behavior is defined by the functions, the state by the variable content.
• Created with declaration and definition similar to basic variable typesClassname objectname;
• Use . operator to access object variables and functions: objectname.function();
![Page 34: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/34.jpg)
C\C++ with Arduino
![Page 35: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/35.jpg)
C\C++ with Arduino
Control structures:Conditions:
• if (x<10) {...} else{...}Loops:
• while (x<10){...}
• for(int i=0; i<10;i++){...break;...continue;..}
• switch(variable){case 1: ... break;}
http://www.cplusplus.com/doc/tutorial/control/
![Page 36: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/36.jpg)
C\C++ with Arduino
![Page 37: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/37.jpg)
C\C++ with Arduino
![Page 38: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/38.jpg)
C\C++ with Arduino
![Page 39: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/39.jpg)
C\C++ with Arduino
Variable arrays: An array is a collection of variables that can be accessed with an index number.
Declaration and definition:int myInts[6];
Declaration, definition and initialization:int myPins[] = {2, 4, 8, 3, 6};int mySensVals[6] = {2, 4, -8, 3, 2};char message[6] = "hello";
Use: myInts[5]=myInts[4]+2;http://arduino.cc/en/Reference/Array
http://arduino.cc/en/Reference/Array
![Page 40: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/40.jpg)
C\C++ with Arduino
![Page 41: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/41.jpg)
Libraries
• Libraries in the Arduino world are reusable code snippets, which usually encapsulate complex hardware access or algorithms
Install:
• Copy library directory into the libraries folder of your Arduino IDE
• Restart the IDE
• Use: Menu - Sketch - Import Library
http://arduino.cc/en/Reference/Libraries
![Page 42: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/42.jpg)
C\C++ with Arduino
![Page 43: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/43.jpg)
Hardware Setup
![Page 44: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/44.jpg)
Brushless motor
![Page 45: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/45.jpg)
Propeller
![Page 46: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/46.jpg)
Servo
![Page 47: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/47.jpg)
LiPo-Battery
![Page 48: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/48.jpg)
Sonar - Ultrasonic-Range-Finder
![Page 49: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/49.jpg)
Hardware setup
Signal
VCC 5V
GND
Brushless-Motor
ESC
Order
either way
ArduinoVin
GND
Pin9
ServoSignal
VCC 5V
GND
Pin10 5V GND
Sonar
GND ECHO TRG VCC
GND Pin12 Pin13 5V
Signal
VCC 5V
GND
Brushless-Motor
ESC
LiPo-Battery
Order
either way
- +
ArduinoVin
GND
Pin9
ServoSignal
VCC 5V
GND
Pin10 5V GND
Sonar
GND ECHO TRG VCC
GND Pin12 Pin13 5V
![Page 50: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/50.jpg)
Useful Things
![Page 51: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/51.jpg)
How to control brushless motors and servos
• Brushless motors are controlled by ESC
• ESC and servos are controlled by a PWM signal
• Arduino Servo library generates PWM signals
• ESC will not use the full rangeof 180°
• For usage, check example code of Servo library
![Page 52: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/52.jpg)
How to control brushless motors and servos
![Page 53: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/53.jpg)
How to use the sonar
![Page 54: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/54.jpg)
How to deal with time
• Get timestamp in milliseconds:o int now = millis();
• Delay or wait for a while:o delay(1000);o Will not affect Servo/Brushless PWM
generation
![Page 55: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/55.jpg)
Debug practise
• Use Serial Monitor to read write outs created by your device while it is connected to usb
• Serial Monitor: Arduino-IDE -> Tools -> Serial Monitor (CTRL+SHIFT+M)
![Page 56: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/56.jpg)
Debug practise
• Print text: o Serial.print("TESTTEXT");o Serial.println("TESTTEXT")
;
• Print variableo Serial.print(variablename)
;o Serial.println(variablenam
e);
![Page 57: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/57.jpg)
General tips
Good programmers are not reinventing the wheel, copy and paste is king!
But be careful,
and learn from your copies!
![Page 58: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/58.jpg)
Additional requirements
![Page 59: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/59.jpg)
Requirements
• Shut off engines after 10 seconds of full collision, sonar distance below 10cm
• Shut off engines after 3min of runtime
![Page 60: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/60.jpg)
Requirements
Design boat/vehicle
Assemble/Solder electronics
Program Drone
Quality control at help desk before plugging in
the battery
Test vehicle in water pool before inserting
electronics
Put everything together
Dry testing without propeller
First supervised test in pool without
propeller
Test with propeller in pool
Test in lake
![Page 61: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/61.jpg)
Further Information
![Page 62: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/62.jpg)
Further information
• Examples included in the Arduino IDE
• Arduino tutorials:
http://arduino.cc/en/Tutorial/Sketch
http://www.ladyada.net/learn/arduino/index.html
• Simple sonar example projects:
http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/
http://tutorial.cytron.com.my/2012/10/11/testing-ultrasonic-ranging-module-sn-hc-sr04/
• Sonar libararies:
https://code.google.com/p/arduino-new-ping/
http://freecode.com/projects/hc-sr04-ultrasonic-arduino-library
![Page 63: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/63.jpg)
Further information
• Controlling a brushless motor and ESC with Arduino:
http://techvalleyprojects.blogspot.com/2012/06/arduino-control-escmotor-tutorial.html
![Page 64: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/64.jpg)
The URL for the forum
moot.it/makeweekened
![Page 65: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/65.jpg)
![Page 66: Makeweekend 2013 Robotics - Arduino and Hardware Introduction](https://reader036.vdocuments.us/reader036/viewer/2022062322/55cf94b3550346f57ba3d1ff/html5/thumbnails/66.jpg)