Advertisement

Quick Links

V2.0 User Manual
A uniquely designed, complete robot kit to get you started in
building and programming!

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Pi-Bot v2.00 and is the answer not in the manual?

Questions and answers

Summary of Contents for STEMCenter USA Pi-Bot v2.00

  • Page 1 V2.0 User Manual A uniquely designed, complete robot kit to get you started in building and programming!
  • Page 2: Table Of Contents

    Table of Contents Introduction: Before You Begin ..........................4 Chapter 1: Introduction to Electronics ......................... 5 Electricity ................................5 Resistors................................6 Understanding Voltage, Current, and Resistance ..................... 7 Circuit Symbols ..............................7 Breadboards ..............................8 Building a Basic Circuit ............................9 Chapter 2: Basic Hardware Programming ......................
  • Page 3 Assembly ................................. 70 Wiring the Distance Sensor ..........................73 Wiring the LEDs............................... 74 Programming the Distance Sensor ......................... 76 Chapter 8: Line Tracking ............................. 85 Line Tracking Sensor Assembly ........................85 Complete Pi-Bot Wiring Schematic ......................... 87 Basic Line Following Program ......................... 89 Line Following –...
  • Page 4: Introduction: Before You Begin

    Introduction: Before You Begin Congratulations on purchasing your Pi-Bot Robot Kit! The Pi-Bot manual is meant to assist you in building and programing. All of the instructions in this manual are designed to provide an easy step-by- step method for every aspect of building your Pi-Bot, from start to finish. Make sure to take your time and read through each lesson carefully.
  • Page 5: Chapter 1: Introduction To Electronics

    Chapter 1: Introduction to Electronics Digital devices are widely used. Earlier, most electronic devices contained analog circuits which dealt with continuously changing signals. Today, digital circuits are widely used. Personal computers and smart phones are examples of digital devices that contain digital circuits. Digital devices use discrete values which are zero (0) or one (1).
  • Page 6: Resistors

    Resistors A resistor is an electronic component that resists the flow of electrical current. A resistor is typically used to control the amount of current that is flowing in a circuit. Resistor converts electrical energy into heat. Resistance is measured in units of ohms (Ω) and named after George Ohm, whose law (Ohm’s Law) defines the fundamental relationship between: ...
  • Page 7: Understanding Voltage, Current, And Resistance

    Understanding Voltage, Current, and Resistance Ohm’s Law: V = IR Units:  Current (I) – Ampere  Voltage (V) – Volt  Resistance (R) – Ohm Figure 1.3 Circuit Symbols Below are basic circuit symbols that you should familiarize yourself with, as shown in Figure 1.4. Figure 1.4 Be able to draw a circuit diagram for each circuit you create using the above symbols.
  • Page 8: Breadboards

    Breadboards A breadboard is a reusable platform to quickly build and test electronic circuits. Breadboards are a rectangular array of electrical contacts. Each contact in a row is electronically the same. See Figure 1.5, below, for various breadboard sizes. Figure 1.5 Each row is electrically the same.
  • Page 9: Building A Basic Circuit

    LED stands for light emitting diode. LEDs work like a one way street. They allow current to flow in one direction only. The longer end of the LED is positive (anode) and the shorter end is negative (cathode). An LED requires an appropriate resistor, based on the power supply, to drop the voltage. A simple LED circuit is shown in Figure 1.7.
  • Page 10: Chapter 2: Basic Hardware Programming

    Chapter 2: Basic Hardware Programming The Basic Arduino Program In this lesson, you will learn how to program the input/output ports of your STEM Board microprocessor. The focus will be on functions needed for programming your robot. It is assumed that you have a basic understanding of the C programming language, as described in Lesson 3: Introduction to C Programming.
  • Page 11: Digital Input/Output

    2. The specifications for the STEM Board microprocessor are: Microcontroller ATmega328 Operating Voltage Input Voltage (recommended) 7 – 12V Input Voltage (limits) 6 – 20V Analog Input Pins Digital I/O Pins 14 (of which 6 provide PWM output) DC Current for 3.3V Pin 50 mA Flash Memory 32 KB of which 0.5 KB used by bootloader...
  • Page 12 constants. The use of predefined constants, such a HIGH and LOW, make the program much more readable end easier to debug.  The delay is used to pause the program for 0.1 seconds. Exercise 1 1. After you get the program: led_01.ino to run, modify it to: a.
  • Page 13: The Light Emitting Diode (Led)

    The Light Emitting Diode (LED) 1. LED is short for Light Emitting Diode and is shown in simple circuit in Figure 2.4. Figure 2.4 2. The LED conducts electricity only in one direction. If the polarity of the diode is reversed, it will not damage the LED, it will simply not emit light.
  • Page 14: Breadboarding To Prototype

    Breadboarding to Prototype 1. The protoboard, commonly referred to as a breadboard, is used for prototyping electrical circuits without needing to solder everything together. The term protoboard differentiates from breadboards as protoboards typically require soldering while breadboard do not. 2. A diagram of the breadboard layout is shown in Figure 2.5. Figure 2.5 3.
  • Page 15: Chapter 3: Introduction To C Programming

    Chapter 3: Introduction to C Programming This lesson assumes that the Arduino IDE is correctly installed on your computer and tested. If not, refer to Appendix A to follow the installation process. The Basic Arduino Program 1. Let’s start with a simple program, as shown in Figure 3.1. This is the same program referenced in Appendix A.
  • Page 16: Constants And Variables

     In the case of the function Serial.begin(9600), the name of the function is Serial.begin and when called, the program passes the value of 9600, which in this case is the baud rate (transfer rate) for the serial communication. For another example, when the function Serial.println("Hello World");...
  • Page 17 #define var1 1 int const var3=1; void setup() Serial.begin(9600); void loop() const int var2 = 1; int var4; int var5=1; boolean var6=false; var4=1; // The value of c4 is now defined Serial.print("var1 = "); Serial.print(var1,DEC); Serial.print(" var2 = "); Serial.print(var2,DEC); Serial.print("...
  • Page 18 4. You have two required functions: setup () and loop () 5. We have added #define var1 1 to the first line of the program. This var1 is now a user defined constant that cannot be changed .This also has a global definition, that is, var1 is equal to 1 for all the functions.
  • Page 19: Control Statements

    Control Statements 1. The control statement is used to control the flow of the program. In this section we will be addressing three of the commonly used control statements: a. if statement b. for statement c. do while statement 2. The form of the if statement is as follows: if(logical test) statements are executed if logical true.
  • Page 20 4. Let’s do the example as shown in Figure 3.3. void setup() Serial.begin(9600); void loop() int var1, var2; var1 = 1; var2 = 1; if( var1 == 1) var2 = 2; Serial.print("var1 = "); Serial.print(var1, DEC); Serial.print(" var2 = "); Serial.println(var2, DEC);...
  • Page 21 8. Time for another example! Copy the program Fourth.pde shown in Figure 3.4. void setup() Serial.begin(9600); void loop() int var1; var1 = 3; Serial.print("var1 = "); Serial.print(var1, DEC); if( var1 == 1) Serial.println(" is equal to 1"); else if( var1 < 1) Serial.println("...
  • Page 22 Exercise 2 Using the Fourth.ino program, edit the following:  Change the value of var1 = 0. What part of the if statement prints the results?  Change the value of var1 = 1. Why does the program say it is less than 1, but does not say it is less than 4? ...
  • Page 23 e. Experiment by changing the initial value of count and the logical test. i. Note: Make sure that you SAVE on a regular basis when you are testing your code. It is easy to get the program into an infinite loop, and sometime you may need to kill (stop) the program.
  • Page 24 Advanced Exercise 1. Modify the program to count from -5 to 5. For the negative numbers, the program should state the factorial could be computed. Congratulations on completing your Introduction to C programming!
  • Page 25: Chapter 4: Assembling Your Gearbox

    Chapter 4: Assembling Your Gearbox These are the first steps to enjoying your new Pi-Bot kit. Follow the directions and you'll be ready to program it in no time! This first lesson covers how to build your gearbox, which will power your Pi-Bot. The Tamiya Double Gearbox comes with various gearbox options.
  • Page 26 2. Open the bag of hardware, as shown in Figure 4.2, and verify its contents. Figure 4.2  Two (2) electric motors with wires  Two (2) hex shafts approximately 15mm in length  Two (2) smooth shafts approximately 28mm in length ...
  • Page 27 3. Open one of the bags of gears, as shown in Figure 4.3, and verify its contents. Figure 4.3  One (1) yellow crown gear  Three (3) blue 2-step gears  One (1) yellow final gear  Two (1) yellow long spacers and two short spacers (spaces are attached, as seen in the top yellow part of Figure 1.3) 4.
  • Page 28 6. Identify the gearbox housing, as shown in Figure 4.5. Figure 4.5 7. Twist the gearbox housing parts apart, so they match Figure 4.6. Notice which housing parts are considered “left” and “right.” Left Right Side Side Figure 4.6...
  • Page 29 8. Organize the parts for ease of assembly. It is recommend to have a large open table space to avoid losing any small parts. Identify that all parts are present, as shown in Figure 4.7. Figure 4.7...
  • Page 30: Assembly Of The Gearbox

    Assembly of the Gearbox 1. Twist the large yellow bushing off of the yellow part, as shown in Figure 4.8. You will not need the small yellow bushing. Figure 4.8 2. Press a yellow bushing onto each of the smooth shafts, as shown in Figures 4.9 and 4.10. There should be 3mm of exposed shaft from the flanged side of each bushing.
  • Page 31 5. Twist off the top of the tube of grease. Save the top as it can be used to seal the tube later on. 6. Place two eyelets into the inside center holes of the right side of the housing, as shown in Figure 4.13.
  • Page 32 8. Insert the 26mm (longer) end of the hex shaft into the rear eyelet, as shown in Figure 4.15. Figure 4.15 9. Locate the smooth shaft assembly, which was built in step 1, and apply a small amount of grease to the 3mm end, as shown in Figure 4.16.
  • Page 33 10. Insert the 3mm (shorter) end into the remaining eyelet on the gearbox housing, as shown in Figure 4.17. Figure 4.17 11. Insert a yellow final gear onto the hex shaft, such that the hub of the gear enclosed the gear hub.
  • Page 34 12. Apply a small amount of grease to both of the exposed shafts on the inner part of the gearbox housing, as shown in Figure 4.19. a. Note: Do not apply grease to the outside portion of the hex shaft. This is where the wheel will be attached.
  • Page 35 14. Place a second blue 2-step gear on the hex shaft such that the smaller diameter mates with the larger diameter gear from the first blue 2-step gear, as shown in Figure 4.21. Figure 4.21 15. Place the yellow crown gear on the smooth shaft, such that the small diameter gear mates with the larger diameter gear of the second blue 2-step gear, as shown in Figure 4.22.
  • Page 36 16. Place one 4mm spacer (silver) onto the hex shaft, as shown in Figure 4.23. Figure 4.23 17. Take (2) eyelets, and place one on the smooth shaft and one on the hex shaft, as shown in Figure 4.24. Figure 4.24 18.
  • Page 37 a. Note: In Figure 4.26, there is an open area where you can see all the gears. If you see a grey horizontal shaft going through this area, you have mated the center housing backwards. Figure 4.25 Figure 4.26 19. After ensuring that the gearbox housing parts are mated correctly, locate and insert three 17mm self-tapping screws to hold the assembly together, as shown in Figure 4.27.
  • Page 38 Figure 4.28 22. Verify that both sides of the housing are mated to the center correctly. If so, then locate and insert three 17mm self-tapping screws to hold the assembly together, as shown in Figure 4.29. The screws should be tightened and snug. a.
  • Page 39 23. The left side of the housing may not close correctly, as shown in Figure 4.30. Do not force them together, as this will damage the housing. Instead, while holding the two parts together, use the hex wrench to loosen the left side Grub screw. See Figures 4.31 and 4.32. This will allow the two parts to mate properly.
  • Page 40 24. The complete gearbox housing is shown in Figure 4.33. Figure 4.33 25. Attach a purple pinion gear on to each of the two motor shafts, as shown in Figure 4.34. Do not push on the motor body. Support the opposite end of the shaft, as shown in Figure 4.35. Your motors should look like Figure 4.36.
  • Page 41 Figure 4.36 26. Install the motors into the front of the gear assembly making sure that the electrical contacts face outward. See Figures 4.37 and 4.38. a. Note: Wires have already been soldered to your motors. Place the motors so that the blues and whites are aligned, as shown in Figure 4.38.
  • Page 42 27. Slip on the motor retaining band (T5) in between the motors, as shown in Figures 4.37, 4.39, 4.40. Figure 4.39 Figure 4.40 28. Lastly, apply grease to all of the gears, as shown in Figure 4.41. Figure 4.41 Note: You will have some leftover parts after your assembly. This is okay! Keep these spare parts in a bag for future projects.
  • Page 43: Chapter 5: Building Your Basic Pi-Bot

    Chapter 5: Building Your Basic Pi-Bot Now that you've successfully completed assembling your gearbox, it's time to build your Pi-Bot! 1. Identify your Pi-Bot chassis. Remove the brown tape overlaid on the chassis, as shown in Figure 5.1. The top side can be identified by the countersink holes. You can also identify the top side by the additional switch hole on the right side of the chassis.
  • Page 44: Mounting The Gearbox

    Mounting the Gearbox 3. Locate two (2) flat head 4-40 x 3/8’’ screws and two (2) 4-40 nuts. 4. Locate your assembled gearbox from the previous chapter. Flip your chassis over, so that the gearbox will be mounted to the underside of the chassis, as shown in Figure 5.3. Notice how the motors point to the rear of the body.
  • Page 45: Installing Your Switch

    Installing Your Switch 6. Locate the bag with the following items, as shown in Figure 5.5: a. Switch with soldered wires b. Flat and locking washers c. Two (2) matching nuts d. Note: Pay careful attention to how the nuts and washers are arranged in the proper order for installation in Figure 5.6.
  • Page 46 8. Insert two (2) 4-40 x 3/8” screws in the two holes next to the switch at act as terminal blocks. When mounting the screws, the eyelets of the switch wires should be captive, as shown in Figure 5.7. Figure 5.7 9.
  • Page 47: Setting Up Your Caster Wheel

    Setting Up Your Caster Wheel 10. Locate the front caster parts as shown in Figure. 5.9. a. Note: You will need to remove the brown cover from the clear component, as shown in Figure 5.10. Figure 5.9 Figure 5.10 11. Assemble the front caster using the provided screws and nuts, as shown in Figure 5.11. Notice, we use the large spacer to make the Pi-Bot level.
  • Page 48 Figure 5.12 13. Mount the assembled caster to the rear bottom of the body, as shown in Figure 5.13. Route the motor wires through the hole above the caster. Figure 5.13 14. Now we will install the 1” standoffs for the front line sensor. Locate the two remaining countersunk holes on your Pi-Bot chassis.
  • Page 49: Assembling Your Tires

    Figure 5.14 Assembling Your Tires 16. Locate the Sports Tire set, as displayed in Figure 5.15. Figure 5.15 17. Assemble the wheels as shown in Figure 5.16. a. The wheel hubs should be attached to maximize the wheel base. In other words, insert the screws into the deeper side of each wheel and the nuts into the more shallow side.
  • Page 50 You can find detailed instructions at: https://www.youtube.com/watch?v=mWdVtPwpJ8M Figure 5.16 18. The Pi-Bot with correctly installed wheels are depicted in Figures 5.17. a. Note: Do no force the wheels all the way in! Keep a reasonable clearance between the tires and the body. Figure 5.17...
  • Page 51: Mounting The Stem Board Microcontroller

    Mounting the STEM Board Microcontroller 19. Now you will begin mounting your Arduino-compatible STEM Board microcontroller. Locate the following items, as shown in Figure 5.18: a. Four (4) 1” nylon b. Clear plastic microprocessor mounting board c. Four (4) 4-40 x 1/2” screws d.
  • Page 52 21. Attach the STEM Board microprocessor to the top of the clear plastic mounting plate using four (4) 4-40 x 3/8” screws and four (4) 4-40 nuts. See Figures 5.20 and 5.21. a. Note: There is only one configuration that allows the STEM Board to fit onto the mounting plate.
  • Page 53 Figure 5.22 23. Stack the rails so that the thinner one is adjacent to the chassis, and the thicker rail is on top. This creates a notch for the battery pack slider. Pay careful attention to Figure 5.23 to see how the rails are oriented.
  • Page 54: Setting Up Your Battery Pack Slide

    Setting Up Your Battery Pack Slide 24. The battery pack slide will be inserted into the battery rails you created in Step 22. Locate the following items, as shown in Figure 5.24. a. The three AA battery pack carrier b. Clear plastic battery slide c.
  • Page 55 26. Insert the completed battery pack slide into the slots underneath the STEM board mount. You may need to loosen or tighten the underside screws to lock the battery slide in place. See Figure 5.26 for the inserted battery pack slide. Figure 5.26 27.
  • Page 56 28. Place one Velcro on the underside of the 9V battery case and one of the Pi-Bot chassis. Refer to Figure 5.28 for the placement of the Velcro. a. Note: The battery case should have the switch facing upwards. Figure 5.28 Congratulations! You have completed the assembly of the Basic Pi-Bot! Your Pi-Bot should look similar to Figure 5.29.
  • Page 57 Figure 5.29 Now that your Basic Pi-Bot is complete, we are now ready for the most exciting part – making your Pi- Bot move! The next lesson will go over the motor wiring.
  • Page 58: Chapter 6: Wiring And Programming Your Basic Pi-Bot

    Chapter 6: Wiring and Programming Your Basic Pi-Bot Now that you’ve successfully completed building your basic Pi-Bot, you are now ready to wire your motors! 1. Locate two nuts and the positive (red) jumper wire with a tab from your bag of wires, as shown in Figure 6.1.
  • Page 59 a. Note: The motor controller has multiple solder pads on the right side of the board. These solder pads will be used to orient the controller on the breadboard. When installing the controller in the breadboard, make sure the solder pads are on the right side of the body as shown in Figure 6.4.
  • Page 60: Basic Motor Wiring Schematic

    5. Route your motor wires through the center hole, if you have not done so already. We have labeled our motor wires with “L” and “R” to make the wiring more clear. See Figure 6.5. Figure 6.5 Basic Motor Wiring Schematic 6.
  • Page 61: Wiring The H-Bridge

    Wiring the H-Bridge 7. Connect positive (red) wire from the right power switch terminal to motor controller pin 15. See the schematic in Figure 6.6 and Figure 6.7 Figure 6.7 8. Locate four (4) white male-male wires and one (1) black male-male wire, as shown in Figure 6.8. Figure 6.8...
  • Page 62 9. Connect the following wires, as shown in Figures 6.9 and 6.10: a. Ground (black) male-male wire from the STEM Board to motor controller pin 1. b. Battery pack negative (black) wire to motor controller pin 16. Figure 6.9 Figure 6.10 10.
  • Page 63 Figure 6.11 11. Connect the motor controller to the STEM Board as shown in Figure 6.12. The connections between the STEM Board and H-Bridge should be as follows: a. STEM Board Pin 3 will go to H-Bridge Pin 3 b. STEM Board Pin 5 will go to H-Bridge Pin 4 c.
  • Page 64 Figure 6.12 12. Notice that H-Bridge Pin 2 is not used. 13. A close up view of the completed breadboard is shown in Figure 6.13. Figure 6.13 14. Make sure the power switch is turned OFF. Remember, the power switch is arranged in the OFF position when it is pointing to the rear of your Pi-Bot, or away from the empty terminal.
  • Page 65 Figure 6.14 15. Insert a 9V battery into your 9V battery case. You will need to unscrew the bottom lid. 16. Plug the 9V battery into the 9V socket on the STEM Board to test it out. Look for the green LED on the STEM Board to turn on.
  • Page 66: Making Your Pi-Bot Move

    Making Your Pi-Bot Move 1. Go to http://www.stemcenterusa.com/pi-bot/downloads-/ and download the sample codes. 2. Open Arduino IDE and open the “MotorTest” program a. You may need to navigate to the appropriate folder on your computer. 3. You can enter and run the program in Figure 6.15, shown on the next page. MotorTest Comments Download this program and run it.
  • Page 67 Figure 6.15...
  • Page 68 The program provided in Figure 6.15 is not an efficient method for programming motor controls. The next program, shown below in Figure 6.16 is similar to the previous program except now it uses function calls. Using function calls makes the program compact. You can make function calls as many time as you need without rewriting the same code.
  • Page 69 Exercise 1 Using the program provided in figure 2.40, make modifications to control the motors to move the wheels forward for 5 seconds, stop for 2 seconds, reverse for 3 seconds, and stop indefinitely. Exercise 2 Add another function called TURN. Have it turn the wheels in opposite directions. This will cause your Pi- Bot to spin in circles.
  • Page 70: Chapter 7: Distance Sensor

    Chapter 7: Distance Sensor The HC-SR04 ultrasonic sensor uses sonar to determine the distance to an object just like bats and dolphins. Since they are used to determine distance, ultrasonic sensors are popularly known as distance sensors. Ultrasonic sensors offer excellent non-contact range detection from 2cm to 400 cm or 1” to 13 feet.
  • Page 71 3. Connect four (4) 20 cm female-male wires to the ultrasonic sensor as follows, as shown in Figure 7.3: a. VCC – Red b. Trig – Yellow c. Echo – Green d. GND – Black Figure 7.3 4. Attach the ultrasonic sensor using four (4) 0-80 x 1/2" screws and nuts (they come in a separate bag).
  • Page 72 5. Use one (1) 4-40 x 3/8” screw and nut to mount the ultrasonic assembly on the left side of the body, as shown in Figure 7.5. Figure 7.5 6. Route all of the wires underneath the STEM Board, as shown in Figure 7.6. Figure 7.6...
  • Page 73: Wiring The Distance Sensor

    Wiring the Distance Sensor 1. Locate two (2) male-male 20 cm wires, 1 black and 1 red. See Figure 7.7. Figure 7.7 2. Jumper wires are used to create more pins for power and ground. They also help clear the clutter of wires.
  • Page 74: Wiring The Leds

    Black – GND Jumper Red – 5V Jumper Figure 7.9 3. Connect the four (4) 20cm ultrasonic wires to the following: a. VCC – Red to breadboard positive 5V (use the jumper wires you have already set up so that the VCC lead connects to the breadboard) b.
  • Page 75 5. Connect the lead of the Red LED through the dropping resistor to STEM Board digital pin 13. Connect the lead of the Green LED through the dropping resistor to STEM board digital pin 12, as shown in Figure 7.11. a.
  • Page 76: Programming The Distance Sensor

    Programming the Distance Sensor The HC-SR04 ultrasonic distance sensor board is a practical component for your Pi-Bot. Once programmed, your Pi-Bot will be able to detect an object in front of it and determine its distance. Note: VCC is the board +5V power supply and the wire is always colored red. The Ground wire is always colored black.
  • Page 77 UltraSonicSensorTest Program Now, let's use the ultrasonic sensor to control an LED. Download the program UltraSonicSensorTestwithLED and run it. The RED LED will light whenever the distance to an object is less than 10cm.
  • Page 78 UltraSonicSensorTestwithLED Program...
  • Page 79 Using Interrupts (advanced programming) It is important that the program does not spend all of its time polling the sensor to determine the distance to an object. To allow the STEM Board processor to perform more than one task such as sensing the distance using the ultrasonic and controlling the motors for line following, interrupts will be used.
  • Page 80 ObstacleAvoidance Program...
  • Page 81 ObstacleAvoidance Program CONTINUED Obstacle Avoidance with LED Now, let's use the ultrasonic sensor to control two LEDs as the robot moves forward and detect an obstacle. Download the program ObstacleAvoidancewithLED and run it. GREEN LED will be on as the robot moves forward and the RED LED will light up when the robot encounters an obstacle.
  • Page 82 ObstacleAvoidancewithLED Program...
  • Page 83 ObstacleAvoidancewithLED Program CONTINUED...
  • Page 84 ObstacleAvoidancewithLED Program CONTINUED Exercise 1 Modify the forward speed and the backward speed of your Pi-Bot. Try different speeds on the two wheels when traveling in reverse. Exercise 2 Upon detecting an obstacle, have your Pi-Bot reverse in different directions. For example, upon detecting the first obstacle, have your Pi-Bot reverse while turning to the right.
  • Page 85: Chapter 8: Line Tracking

    Chapter 8: Line Tracking Line following is a very important and fun activity. Many real world systems including robots performing warehouse operations use line following activities. Speaking of warehouse operations, it may be interesting to know that not too long ago, Amazon paid almost 1 billion dollars for Kiva System, a company that makes robots for warehouse operations.
  • Page 86 Locate two (2) 4-40 3/8” screws to attach the line sensor to the nylon spacers. See Figure 8.2. a. Note: Notice the red LEDs are pointed upwards. Figure 8.2 Figure 8.3 shows the view of the robot from the underside showing the line sensor wiring. Figure 8.3 Route the wires through the hole on top of the caster wheel.
  • Page 87: Complete Pi-Bot Wiring Schematic

    Connect the wires as follows: a. Power (Red) – to STEM Board 5V or 5V on breadboard b. L (Yellow) – to STEM Board Pin 7 c. C (Green) – to STEM Board Pin 8 d. R (Blue) – to STEM Board Pin 10 e.
  • Page 88  By moving the sensors over a black line, you should see the outputs toggle between 0 and 1. If this test is successful, you are ready to begin line following! LineFollowingSensorTest...
  • Page 89: Basic Line Following Program

    Basic Line Following Program We will now discover how the line sensors will allow your Pi-Bot to detect and track a line. Line following consists of two parts: Determining the position of your Pi-Bot to a black line First, your Pi-Bot determines its position relative to a black line with the use of line sensors, located in the front.
  • Page 90 Download and run the following program: LineFollowing Program...
  • Page 91 LineFollowing Program CONTINUED...
  • Page 92 LineFollowing Program CONTINUED Exercise 1 Write a program to follow a line with just one light sensor (use any, L, C, or R)? Exercise 2 Write a program to follow a line with two light sensors, L and R. Exercise 3 Compare the performance of all three programs...
  • Page 93: Line Following - Advanced Programming

    Line Following – Advanced Programming More advanced programming can be created to allow your Pi-Bot to operate more precisely. Run the program, AdvancedLineFollowing below. This is an example of a more sophisticated line following algorithm. While your Pi-Bot will not run any faster using this program, it is more reliable and can easily track around sharp corners.
  • Page 94 AdvancedLineFollowing Program CONTINUED...
  • Page 95 AdvancedLineFollowing Program CONTINUED...
  • Page 96 AdvancedLineFollowing Program CONTINUED...
  • Page 97 AdvancedLineFollowing Program CONTINUED Exercise 4 (Advanced) Combine the line following with the collision detection. Your Pi-Bot should follow a black line, until an obstacle is placed in front of it, at which time it stops.
  • Page 98: Appendix A: Installing And Testing The Ide

    Appendix A: Installing and Testing the IDE Preparing the Computer 1. Go to www.arduino.cc and download latest version of the Arduino IDE which is the Arduino 1.5.6-r2-windows.exe file. The download may take several minutes, as the file size is 66 MB. See figure A.1.
  • Page 99 Figure A.3 4. Select your destination folder and click Install, as shown in Figure A.4. Figure A.4 5. After installation is complete, you should see the Arduino Setup: Completed dialog box, as shown in Figure A.5.
  • Page 100 Figure A.5 6. Use the Arduino command in the Start menu, or click on the icon on the desktop to open the program, as shown in Figure A.6. Figure A.6...
  • Page 101: Connecting The Arduino To The Computer

    Connecting the Arduino to the Computer 1. Close the IDE. 2. Plug the STEM Board microprocessor into an available USB port using the supplied USB cable. 3. The first time you plug the STEM Board into your computer, Windows should automatically detect the newly attached device and attempt to find a driver for it.
  • Page 102 5. Scroll down and double click on the Arduino UNO icon, as shown in Figure A.8. Figure A.8 6. In the Arduino UNO dialog box, select the Properties tab, as shown in Figure A.9. Figure A.9...
  • Page 103 7. Next, select the Change Settings button, as shown in Figure A.10. Figure A.10 8. Select the Update Driver… button to update the driver software, as shown in Figure A.11. Figure A.11...
  • Page 104 9. Windows will prompt you, whether you would like Windows to automatically search for driver software or browse your computer. Choose the second option: Browse my computer for driver software, as shown in Figure A.12. Figure A.12 10. Use the Browse button and select the location the C:\Arduino\arduino-0022\drivers, as shown in Figure A.13.
  • Page 105: Testing The Ide

    11. A Windows message should popup indicating that the device is ready for use. 12. We are now ready to test the system. You are now ready to begin Chapter 3: Introduction to C Programming. Testing the IDE 1. Open up the IDE. It should look similar to the IDE shown in Figure A.14. a.
  • Page 106  Button 2, the STOP button, is used to stop the execution of the program. This is useful for when you need to stop a runaway program. Note, however, there will be times that the STOP button will not stop your code, and you will need to unplug the Arduino microprocessor from the USB and/or shut down the IDE.
  • Page 107 4. Make sure that the IDE is set up for Arduino UNO. Using Tools  Board, select the Arduino UNO, as shown in Figure A.15. Figure A.15...
  • Page 108 5. Next, check that the STEM Board microprocessor is connected to a USB port. Do this by clicking Tools → Serial Port, as shown in figure A.16. A serial port must be selected. It will probably not be port 12, as shown in Figure A.16. If you have multiple ports and the IDE cannot communicate with the STEM Board, try changing the ports.
  • Page 109 7. Cut and paste (or type, if you like) the following code into the IDE. See Figure A.17. void setup() // Your setup code here, to run once: Serial.begin(9600); void loop() // Your main code here, to run repeatedly: Serial.println("Hello World"); delay(1000);...
  • Page 110: Appendix B: Complete Pi-Bot Wiring Schematic

    Appendix B: Complete Pi-Bot Wiring Schematic...

Table of Contents