Académique Documents
Professionnel Documents
Culture Documents
Tutorial 2 of 3: Sensors
Getting started
Sign-in to the club's roster: www.psurobotics.org > Member Tools (Top) > Member's Sign-In Get your group's kits Optional Club Resources: Hammond 312 Learning Factory Building materials (Wood, servos, sensors, etc.) Sunday Hours (Sunday, 2pm, 312 Hammond) Other Microcontrollers New motors and motor controllers (Fast!) Load up the RoboWiki tutorial Search: "Tutorial: Tabletop Sensors"
Tutorial Kit
Two Servos One Arduino Microcontroller (Important!) One Proto-Shield USB Cable Small Breadboard Generic Gray Chassis Battery Battery-to-Arduino Converter Wires Sensors!
Sensors?
Sensors: Any device that gets feedback from the real-world Examples: Range finders (IR, Sonar, LIDAR) Smoke detection Light/UV/line detection Sound detection Interface: Analog: Varying voltage with varying input (Easy) Digital: Returns a number or packet of data (Moderate) Competition focus: Range finders (IR, Sonar) for maze navigation Light detection (Find the light bulb or line) for fire / light
UV-Tron
Function: Detects flames / UV energy Positives: Very sensitive Negatives: Very sensitive, hard to interface Interface: Look at RoboWiki for article Signal: Sends a high-signal based on any detection which is caught by Arduino Interrupt handle
Connecting Sensors
Choose any location on your robot, but be wary of: Wires Min/max distance Wide sonar cone Connections: Black: Ground Red: ~5 Volts Yellow/White: Signal Arduino: 14 Digital pins 6 Analog-in pins 3.3 Volts 5 Volts Ground VIN: Battery voltage (Unregulated)
Connecting Sensors
Create a common ~5 Volt line from the Arduino Connect sensor's Red wire to this common line Create a common Ground line from the Arduino Connect sensor's Black wire to this common line Connect the sensor's output to the Analog In on the Arduino Connect the Yellow/White line from the sensor to any of the 6 analog in
Connecting in Software
Download, un-zip, and run the Arduino IDE Connect your Arduino via usb Make sure the correct device is selected Make sure the right COM line is selected
Sensor Configuration
Goal: Find the right ratios for your sensors Starting point: Basic program File > New & File > Save (Choose a name...) Basic code body: void setup() { Serial.begin(9600); } void loop() { int value = analogRead(0); Serial.println(value, DEC); delay(100); }
Explanation
void setup() Main application entry point Only runs once when powered-on or reset void loop() Main code body Runs an infinite number of times int value = analogRead(0); Read an analog value from pin zero Returns 0 to 1023 (Linear to 0V to 5V) Place that value into the variable "value" Serial.println(value, DEC); Print the value of "value" as a decimal to your computer
Resources
Club officers are walking around Use the wiki for your code: Search "Range Finders" or "Range Tutorial" Remember Sonar is linear (Easy to configure) IR is non-linear (Not so fun...) Derive an equation that takes voltage and returns distance Debugging: Returns internal variables to the computer terminal Initialize communication with "Serial.begin(9600)" Send strings with "Serial.println("xyz")" Send integers with "Serial.println(myInt, DEC)"
Your Challenge!
Two parts: Challenge I Interface with one sonar placed in front of the vehicle Have the robot move forward without hitting anything Challenge II Interface with two IR after configuration Try and follow a wall (at any distance you want ) Look through the wiki - There is a solution