The Code Store - Downloadable Examples

Arduino Robot Bonanza

Save time and energy by downloading the program code from Robot Arduino Bonanza. Conveniently organized by chapter. Please refer to the text of the book for more information on using the program code, including hardware connections and external circuitry. Code may include updates, corrections, and additional comments for clarity.

The program code is provided in zip files. Right click over a link and save the file to your computer. Unpack the zip archive and move the folder to your Arduino user directory.

All sketches are provided for Arduino 1.0 IDE or later.

Chapter 2 - Arduino Up and Running

  • LEDFlash - Arduino 101: Alternative LED flasher (adjustable flash interval)
  • PushButton - Arduino 101: React to a pushbutton
  • TwoTone - Arduino 101: Create alternating tone through piezo speaker

Chapter 4 - Programming the Teachbot: Making it Move

Chapter 5 - Programming the Teachbot: Seeing it React

Chapter 6 - Programming the Teachbot: Letting It Explore

  • Teachbot_Ping - Generate a ping on the Parallax Ping ultrasonic distance sensor
  • Teachbot_PingAvoider - Detect close objects and back away from them
  • Teachbot_TurretScan - Scan a servo-operated sensor turret left and right, stopping at intervals to take a reading from a sensor
  • Teachbot_Sharp810 - Read from a Sharp GP2Y0D810 infrared proximity/distance sensor
  • Teachbot_SharpIR120 - Read from a Sharp GP2D120 analog infrared distance sensor

Chapter 9 - Enhancing the Teachbot

  • TeachbotDC_Basic - Run the Teachbot DC through its paces (requires the CompactQik2s9v1 library)
  • TeachbotDC_Speed - Demonsterate speed and direction control of the TeachBot DC gear motors (requires the CompactQik2s9v1 library)
  • TeachbotDC_LinefollowDemo - Demonstrate reading line following sensor array; display only (no motor control - requires the PololuQTRSensors library)
  • TeachbotDC_ReadEncoders - Read the value from analog IR encoders and display in Serial Monitor (for calibration and testing)
  • TeachbotDC_EncodersDemo - Basic demonstration of counting "ticks" of striped wheel encoders (requires the CompactQik2s9v1 library)
  • Babblebot_Demo - Demonstration of Babblebot speech/sound/music hardare (requires the SimpleTimer library)
Special libraries used in chapter 9
  • CompactQik2s9v1 - Revised Pololu motor control library (updated for Arduino 1.0; you may also get the 1.0-compliant version from the Pololu Web site, but do NOT use the older version made for the pre-release versions of the Arduino software)
  • PololuQTRSensors - Revised Pololu QTR line sensor library, verified for Arduino 1.0)
  • SimpleTimer - Simple hardware timer

Chapter 10 - The Amazing Tunebot

  • Tunebot_MotorForward - Run the Tunebot motors forward (basic function and wiring test)
  • Tunebot_MotorExercise - Test Tunebot motor function forward, reverse, turns (watch for thrown tracks!)
  • MIDI_VerySimple - Demonstrate basic MIDI music generation, output middle-C on and off in loop
  • MIDI_Simple - Same as previous but use variable constants to aid in programming
  • MIDI_Chords - Demonstration of iterating through MIDI chords, using separate instruments and constants file (requires constants.h and instruments.h, included in zip)
  • MIDI_ChordsAndMotors - Same as above, and also demonstrates running Tunebot motors
  • MIDI_Piano - Control Tunebot by waving your fingers over the "air piano" sensor on top

Chapter 11 - Going Places with the Telebot

  • Telebot_Remote_SwitchOnly - XBee transmitter code, using just the 5-position control stick switch.
  • Telebot_Remote_CompassOnly - XBee transmitter code, using the Devantech CMPS10 tilt sensor electronic compass.
  • Telebot_Remote_All - XBee transmitter code, using both 5-position switch and CMPS10 tilt sensor/compass.
  • Telebot_Receiver_Switch - XBee receiver code, using just the 5-position control stick switch. (Requires the Pololu CompactQik2s9v1 motor control library.)
  • Telebot_Tilt_Receive - XBee transmitter code, using Devantech CMPS10 tilt sensor. (Requires the Pololu CompactQik2s9v1 motor control library.)
  • Telebot_Backpack - Demo code for superimpsing text over live video using the Parallax Backpack module.
Special libraries used in chapter 11
  • CompactQik2s9v1 - Revised Pololu motor control library (updated for Arduino 1.0; you may also get the 1.0-compliant version from the Pololu Web site, but do NOT use the older version made for the pre-release versions of the Arduino software)

Chapter 12 - Why Did It Have To Be Snakes?

  • Snake_ServoCalibrate - Calibrate servo to center (using pin D9), prior to segment assembly.
  • Snake_ServoSegmentMove - Basic demonstration of sine movement of snake segments, using time-chopped servo delay movements. (Requires MsTimer2 and Metro libraries.)
  • Snakebot_RemoteTest - Verify operation of IR remote control (requires IRremote library).
Special libraries used in chapter 12
  • MsTimer2 - Background timer library using Arduino harder Timer2.
  • Metro - Retriggerable software timer library.
  • IRremote - Universal IR remote send/receive library (used with Snakebot to receive IR commands).

Chapter 13 - Robby Armstrong

  • Servo_Center - Calibrate servo to center (using pin D4), prior to arm assembly.
  • RobbyCalibrate - Calibrate servo positions for home, minimums, maximums (requires Messenger library.
  • RobbySerialMonitor - Display servo positions (for viewing and calibrating) in the Arduino Serial Monitor window.
  • Robby_Control - Main Robby arm control demonstration. (Requires the following libraries: TimedAction, SimpleTimer, and LCDi2cR.
Special libraries used in chapter 13
  • MsTimer2 - Background timer library using Arduino harder Timer2.
  • Messenger - Serial input parsing library.
  • TimedAction - Software timer.
  • SimpleTimer - Software timer (for movement tests; optional, not used in demonstration sketch).
  • LCDi2cR - I2C library for Devantech LCD03 LCD panel and 4x4 matrix keypad.

License: All programming examples listed on this page are released into the public domain.