The Code Store - Code Examples

Robot Builder's Bonanza, Fourth Edition

Save time and energy by downloading the program code from Robot Builder's Bonanza, Fourth Edition. 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.

All 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, PICAXE, or BASIC Stamp user directory.

The fourth edition of Robot Builder's Bonanza was written and released prior to the Arduino 1.0 IDE software. Unless otherwise noted, Arduino sketches are for the pre-release alpha versions (0022 or later) of the IDE. Most sketches will correctly function when imported into the latest IDE, but others may require tweaking. You are also able to compile these sketches with a final pre-release version, still available from the Web site.

Chapter 25 - Robot Movement with Shape Memory Alloy

  • sketch_sma.pde - (Arduino) Demonstration of actuating shape memory alloy (SMA) wire

Chapter 27 - Build Robots with Legs

  • hex3bot.pde - (Arduino) Basic control loop for walking and turning using the Hex3Bot six-legged robot

Chapter 37 - Using the Arduino

Chapter 38 - Using the PICAXE

Chapter 39 - Using the BASIC Stamp

  • bs2-chapter39 (all) - Examples: code repeat, flash LED using gosub, for loop, DC motor control (basic and enhanced), servo control

Chapter 41 - Remote Control Systems

  • joystick.pde - (Arduino) Record and play back motions using an analog joystick
  • sonyremote.bas - (PICAXE) Basic test of receiving signals from Sony remote (includes sonyremote_debug.bas)
  • ir-bot.bas - (PICAXE) Control robot motors using Sony remote control

Chapter 42 - Adding the Sense of Touch

  • switch_mux.pde - (Arduino) Read multiple switch inputs using a 74151 multiplexer IC
  • switch_piso.pde - (Arduino) Read multiple switch inputs using a 74165 parallel-in serial-out shift register IC
  • button_press.pde - (Arduino) Read a switch using an external interrupt rather than a polling loop
  • button_press_enhanced.pde - (Arduino) enhanced version of above, controlling a robot with two servos

Chapter 43 - Proximity and Distance Sensing

  • irpd.pde - (Arduino) Register proximity using infrared receiver demodulator
  • PICAXE IRPD (all) - (PICAXE) Register proximity using IRPD (contains irpd-picaxe-simple.bas, irpd-picaxe-enhanced.bas, and irpd-picaxe-enhanced-serial.bas)
  • gp2d12.pde - (Arduino) Read Sharp GP2D12 infrared distance sensor
  • srf05.pde - (Arduino) Read Devantech SRF05 ultrasonic sensor
  • srf02.pde - (Arduino) Read Devantech SRF02 ultrasonic sensor

Chapter 44 - Robotic Eyes

  • flyeye.pde - (Arduino) Demonstration of compound eye proximity and motion detection
  • flyeye_thresh.pde - (Arduino) Debug version for setting threshold of compound eye photodetectors

Chapter 45 - Navigating Your Robot

  • line_follow.pde - (Arduino) Line following demonstration (uses two emitter/detector pairs)
  • CMPS09.pde - (Arduino) Detect compass bearings using Devantech CMPS09/CMPS10 compass module
  • accel2.pde - (Arduino) Demonstrate reading 2-axis ADXL-series accelerometer

Chapter 46 - Making and Listening to Sound

  • speakjet.pde - (Arduino) Speak a phrase using the Speakjet voice synthesis IC
  • sounddetect .pde - (Arduino) Detect sound using electret microphone preamplifier (example: SparkFun BOB-09964 microphone breakout board)

Chapter 47 - Interacting with Your Creation

  • led.pde - (Arduino) Light a one LED
  • multi_led.pde - (Arduino) Light a multiple LEDs using 74595 shift register IC
  • segment.pde - (Arduino) Demonstrates lighting numerals on a 7-segment LED display using a CD 4511 IC
  • segment_shapes.pde - (Arduino) Demonstrates lighting numerals and arbitrary segments of a 7-segment LED display
  • tones.pde - (Arduino) Play a simple tune
  • lcd16x2.pde - (Arduino) Display message on 16x2 LCD display
  • tricolor.pde - (Arduino) Change colors of a two-color (red/green, plus orange) LED
  • rainbow_led.pde - (Arduino) Change colors of a three-color (red, green, blue) LED

Chapter 48 - Danger, Will Robinson!

  • smoke_detector.pde - (Arduino) Demonstrate interfacing with smoke detector
  • propane.pde - (Arduino) Detect gas using MQ-series air quality sensor
  • temperature.pde - (Arduino) Measure temperature using LM34 temperature sensor

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