6. Testing and Code

Initial Unpowered Testing

Before powering Bootstrap up for the first time there are a few tests you can do to make sure you are less likely to have a catastrophic short.

  • Check your wiring work against the pictures in the assembly instructions to make sure everything is where it belongs.
  • Examine all of your connections carefully to make sure you don’t have any shorts across uninsulated wiring–two uninuslated wires should never touch. You don’t need to remove the prototyping board to examine the bottom side if you checked that carefully during assembly.
  • Check you polarity assignments one more time, using your multimeter in audible continuity mode. Put one probe on the positive pad of the output of the voltage converter. You should get continuity to any header pin in the positive rail, the 5V pin on the Arduino, the VIN and the VCC pins on the motor controller, the power (inside) wires on the bump switches, and Vcc on the ultrasonic sensor. Switch the probe to the negative output pad on the voltage converter.  Now you should get continuity to any header pin in the ground rail, the GND pin on the Arduino, both GND pins on the motor controller, and Vcc on the ultrasonic sensor.

Now give it some power. Insert a mini USB cable into the arduino on Bootstrap. Insert the other end of the cable into your computer. The power lights on the Arduino and the voltage converter should light up and your computer should recognize that you have plugged in a USB device.

Code Examples

If you have an older version of the Arduino software, it is a good idea to bring it up to date at this time. Bootstrap was developed using versions 1.0.6 and 1.6.1.

In order to download and run the following code examples to Bootstrap you need to first:

  • Install the correct drivers for the version of the Arduino Nano you are using. It’s a good idea to make sure you can communicate with your Arduino before proceeding by downloading an example sketch such as Blink to it.
  • Install the NewTone library, which can be found here. NewTone is required for the buzzer in the code examples on this site.
  • Install the NewPing library, which can be found here. NewPing is required for the ultrasonic sensor in the code examples on this site.

If you have not installed libraries in the Arduino development environment before, it’s quite easy. After you have saved the zip file containing the library to your downloads folder, open the Arduino software. Select Sketch > Import Library > Add Library. Then you just click on the downloaded zip for the library to install it. When you are done the new libraries will show up at the bottom of Sketch > Import Library.

Test program

Next download the bootstrap test program

Bootstrap_test

This is a zip file. Unzip it and open it with File > Open in Arduino. The software will create a folder for it and open it.

Attach your Arduino to your computer via a usb cable and run the test program. You will want to open the serial monitor (under Tools) as soon as the lights stop blinking on the Arduino as the serial monitor displays messages taking you through the test. You will also want to hold Bootstrap in the air by the back of the chassis so it does  not drive off your desk during the motor tests.

The test program will do the following, displaying information and prompts on the serial monitor:

  1. Play two tones on the buzzer
  2. Turn the right motor forward at 1/2 speed
  3. Turn the right motor forward at full speed
  4. Turn the right motor in reverse at full speed
  5. Turn the left motor forward at 1/2 speed
  6. Turn the left motor forward at full speed
  7. Turn the left motor in reverse at full speed
  8. Turn both motors forward at full speed
  9. Test the ultrasonic sensor by having you move your hand toward it
  10. Test the left bump switch
  11. Test the right bump switch

After the testing is complete there is a 5 second delay before the sequence repeats.

If your Bootstrap passes all these tests, try disconnecting it, inserting batteries and switching it on while on a smooth floor to see if it runs through the same tests on under its own power (you will need to remember to trip the ultrasonic sensors and the bump switches after test 8).

If your Bootstrap does not respond properly at any step then you know something is not correctly hooked up at that point in the system.

If both of your motors are turning but in the reverse direction indicated in the tests. the simplest thing to do is to unscrew both of them and flip their sides on the chassis. If you have other problems with the motors you can change the pin assignments in the test program (and all other programs provided on this site) instead of resoldering connections, if you prefer (see line 33 in the test program).

The test program is not meant to be an example of efficient programming–everything is done as transparently as possible with heavy comments for study purposes.

Basic navigation program

[under development]

bill@robot50.net