ENGR2210        12 September 2013


Due:  23 (Chris’s Section) or 24 (Gui / Oscar’s Section) September 2013


You should now be able to read and write digital signals, and read analog signals, from inputs and outputs attached to the Arduino. We’ll now introduce you to distance sensors, actuators (in the form of hobby servomotors) and serial ports in order to collect data from the outside world.


The tripod in the image at right holds a laser rangefinder mounted to a small pan-tilt unit.  The backpack strapped to the tripod contains batteries and a laptop for logging ranges measured by the rangefinder.  This system was built by Chris, and used in the Antarctic to build 3D maps of the ice surface  This system also relies on a LIDAR that costs several thousand dollars.

        In this lab, we’ll be attempting to use common, off-the-shelf (COTS) parts to create an approximation of a LIDAR sensor. This is a common type of industrial sensor that characterizes the world by sweeping a laser rangefinding sensor through one or more arcs, then combining the distance and angle data into a 2D or 3D graph.  Mobile robots and industrial automation typically use LIDAR systems for obstacle avoidance and navigation; planes and satellites use LIDAR systems to recreate terrain. We’ll be combining hobby servomotors (which are cheap, position-controlled actuators) and an infrared rangefinding sensor to detect and recreate a diorama.

Hobby servomotors (also known as “hobby servos”) are actuators that were originally designed to control the position of flaps and control surfaces on model airplanes given a basic FM radio signal. They do this by combining a small motor, a gear train to reduce the motor’s output speed and increase its output torque, a potentiometer or encoder to sense the output position, and a small amount of circuitry to automatically control the position of the output given an input command.

A cutaway of a hobby servo showing the motor, geartrain, sensor, and circuit board.

        Hobby servos are now commonly used to generate simple, position controlled motions on small robots because they drastically simplify motion control. The Arduino compiler even has a built-in Servo library that makes controlling hobby servos relatively easy.

        We’ll be using a Sharp infrared distance sensor to detect range. These sensors use an infrared LED and an infrared detector to estimate distance and produce a corresponding analog voltage output. You can read more about the rangefinder here; note that, like many inexpensive sensors, it doesn’t produce a linear output from a linear change in input.  Read the datasheet carefully though - there is a linear relationship lurking someplace that you could consider exploiting...


In this lab you will build a scanning rangefinder out of two hobby servomotors and an infrared distance sensor in order to eventually recreate a 3D scene. This system is complex enough that any small error or misstep early on will give you big errors later that will be extremely difficult to track down; in order to make sure you have as robust a system as possible, we’ll be taking (and documenting) a number of verification steps along the way. These steps include unit testing each part of your system before it gets assembled, characterizing and linearizing your sensor, assembling a simplified representative system to demonstrate system integration, and (finally) fully integrating your entire system. The steps you will be taking in this lab are as follows:

  1. Verify your distance sensor functions as intended by running the “AnalogInput” example program (under the “Analog” example folder - swapping the indicated potentiometer for your distance sensor) and hooking the sensor up to the appropriate pins.
  2. Verify your Arduino can create a serial connection to your computer and successfully relay data from the distance sensor by modifying the “AnalogInOutSerial” example program (under the “Analog” example folder).
  3. Verify your hobby servos function as intended out of the box by modifying the “Sweep” example program (under the “Servo” example folder) after hooking each servo up to appropriate pins.
  4. Design and execute a test procedure in order to collect data on the analog input your Arduino reads and compare it to the actual distance sensed, in order to calibrate your distance sensor.
  5. Given the data you’ve collected thus far, come up with a method to ‘normalize’ your sensor reading on the Arduino, so that your Arduino reports ‘real’ distances to the computer. Once you have an acceptable solution, recreate your test procedure from step 4 and compare distance reported by your sensor to actual distance.
  6. Mount your distance sensor to a single servo. Create a program that sweeps from left to right across the diorama and reports real distances and corresponding servo angles back. Create a graph of the 2D, top-down representation of the diorama scene using the range and sensor angle data you’ve pulled off the Arduino.
  7. Create a pan/tilt head using two servos and your distance sensor. Create a program that sweeps both across and up the diorama and reports real distances and servo angles back. Create a 3D representation of the diorama using the data you’ve pulled off the Arduino.

NOTE: You may process and display output data using programs (MatLab, Python, etc.) of your choice. The only processing requirement of your Arduino is that it send actual distance and servo angles back to your computer, though you can do additional computations in the Arduino if you like.

Lab 1 Bill of Materials (BOM)

1x Sharp GP2Y0A02YK0F Distance Sensor

        2x Hobby Servos

        1x LED

        1x 330-ohm Resistor


        Please hand in a lab report at the end of class that contains the following, at a minimum:

You may choose to write this report as a traditional lab report, or in the form of a tutorial for posting on the web. Paper, PDF, or a link to an HTML website are the only accepted formats. Please don’t send .DOCX files.  They kill kittens.