Step 7. The motors and distance sensor are mounted on the outside of the chassis, so you’ll have to make some holes for the wiring to make a neat job. Using a drill (or scissors), make holes close to where the lead exits each of the motors and another where the lead exits the distance sensor. Pass the leads through the holes.
Step 8. Plug the lead from the lefthand motor into channel 0 of the Mini-IO Shield, the lead from the righthand motor into channel 1, and the lead from the distance sensor into channel 2. In each case, ensure the white wire is the closest to the outer edge of the Arduino Uno board. Use cable ties to tidy up the wiring.
Step 9. Download the IDE for the Arduino board. Extract the files from the Zip archive, preserving the folder structure, then follow the instructions to install the driver. In Windows 7 you’ll find this under ‘Other Devices’; it’ll move to Ports when the driver has been installed. Make a note of its COM number.
Step 10. Start up the IDE by double-clicking the Arduino application. Download the sample code from tinyurl.com/67jwsLe, then open it in the IDE by selecting Open from the File menu. Select Board from the Tools menu and choose ‘Arduino Uno’. Now compile the program using ‘Verify/Compile’ from the Sketch menu.
Step 11. If it’s not still connected from Step 9, connect the junkBot’s Arduino Uno board to your PC using the USB cable. Select ‘Serial Port’ from the Tools menu and choose the COM port that you noted in Step 9. Select ‘Upload to Board’ from the File menu. When the ‘Done uploading’ message appears, disconnect the USB lead.
Step 12. Plug the lead from the battery pack into the Uno board and place the junkBot on the floor facing a wall. It should move forward until it reaches the wall, then turn around and proceed until it finds another wall. If it moves backwards, the two motors have been connected the two wrong way around.
Step 13. Now try modifying the sample code. Edit it using a text editor, such as EditPad Lite. Enter the code in the screenshot in place of the code starting with ‘while(!front_bump())’. The ends of some lines have scrolled off the screen, but anything after a // is a comment and won’t affect operation.
Step 14. Repeat Steps 10, 11 and 12 with this new code. The junkBot should behave as before, but when it reaches a wall it will now stop, back up and turn around. You can now start your own voyage of discovery by altering the software further or writing your own code from scratch.