CSCI 108 Lab 2


In this lab you will test the motors, touch sensors, and light sensors that you wired in Lab 1. You will do this by writing small Interactive C program fragments. Before you can run Interactive C (IC) on the Handy Board, you must download it to the board. As in Lab 1, this lab has two parts. Part 1 will be an introduction to the Handy Board and Interactive C. In Part 2, you will test the motors and sensors.

Getting Started with the Handy Board and Interactive C

Handy Board Software

Before you begin, you will need to find all of the necessary Handy Board software. You can find everything you need in the Interactive C (IC) folder in Applications.

Connecting the Handy Board to a Mac

Once you've located Interactive C, connect the Handy Board to the USB port of one of the Macs in the lab. To do this, you will need to connect the Handy Board to the Serial Interface board with the telephone cable. Then connect the Serial Interface board to the Keyspan adapter using the modem cable. The adapter should then be plugged into the USB port on the back of the computer monitor.

Downloading Firmware

Before actually using IC, you'll need to download the IC firmware to the board. To do this, just double click on Interactive C 4.30 in the Interactive C folder. This will take you through the process of downloading the firmware.

Starting up Interactive C

If you've just downloaded the firmware, then you're in the right place to write and run Interactive C code. If you're coming back to the lab after a break, just double click on the Interactive C 4.30 icon that took you through the firmware downloading process. It will start up IC for you.

Programming in Interactive C

Interactive C provides you with the ability to either write and run full programs or test single expressions or statements in the IC interpreter. The IC window has a central gray area, with a white text area below it. To test individual statements, you can type them into the white text area. Try out a few IC commands such as

1 + 3;

which should give you the value 4.

Now try

printf("Hello Handy Board\n");

which will print the message Hello Handy Board on the LCD screen on the board.

Testing Motors and Sensors

You should have the two motors, two touch sensors, and three light sensors that you wired last week. In order to make the testing of your motors easier, I will provide you with Lego wheels that can be attached directly to the motors. You can use these to get a sense of the direction and speed of your motors.

Record the results of each of your tests. The product to be turned in for a grade will be a summary of your test results.


You should test a number of attributes of your motors: whether they turn on both forward and backward; whether they change speed; whether they turn off.

Connect one of your motors to motor port 0. Then turn it on in the forward direction by typing:


This should turn on the motor at full power.

Now try changing the power of the motor:

motor(0, 10);

Try a variety of power levels.

Now turn off the motor:


Does the motor work correctly? Record your results. What if you turn it on in the backward direction? Does it still work correctly?

Do the same for your second motor.

Now repeat this process for one of the motors and ports 1, 2, and 3. While the primary objective of this lab is to test the wiring you did for the motors and sensors, a second objective is to test the Handy Board you'll be using for the rest of the semester.

To summarize:

  1. Test motor 1 in port 0.
  2. Test motor 2 in port 0 (or any other port of your choice).
  3. Test motor 1 in ports 1, 2, and 3.
  4. Make any necessary repairs to your wiring.

Touch Sensors

Connect one of your digital (touch) sensors to port 7. (The digital ports are those numbered 7-15.) Now type the following in IC:


Record the result.

Now do the same, but with the sensor depressed, and record the result.

Now test your second digital sensor in the same way.

Next, move one of the touch sensors to port 8, and test it there. Does your sensor work correctly? Are both ports operating appropriately? Repeat this for each digital port, recording the results for each port.

To summarize:

  1. Test touch sensor 1 in port 7.
  2. Test touch sensor 2 in port 7 (or any other digital sensor port).
  3. Test touch sensor 1 in ports 8-15.
  4. Make any necessary repairs to your wiring.

Light Sensors

Testing light sensors will be a bit more complicated. You will begin by testing the Lego light sensor in a manner similar to that above for digital sensors. Test the sensor in each port. (The analog ports are those numbered 0-6.) In each instance, record the reading of the sensor when covered (by your hand, for example) and when fully illuminated (with a flashlight, for example).

Once you have completed this, select a single port for each of your remaining light sensors (i.e., the photocells), and explore the full range of readings for each one. Try a variety of different lighting conditions (overhead light on, overhead light off, flashlight pointed directly at the sensor, flashlight pointed directly but at increasing distances, sensor covered by hand, etc.) What do high values correspond to? Low values? What value do you get for the port when no sensor is connected?

Now shield your photocell light sensor. (See page 83 of Martin or my sample light sensors for examples.) What sort of readings do you get now? Try a number of different lighting conditions.

Finally, get a piece of white reflective paper and some black electrical tape. Record the reading you get with each sensor when it is positioned over the white paper and then over the black tape.

To summarize:

  1. Test the Lego light sensor in each port.
  2. Plug photocell 1 into the port of your choice.
  3. Plug photocell 2 into the port of your choice.
  4. Shield the photocells.
  5. Test photocells over white reflective paper and black electrical tape.
  6. Test Lego sensor over white reflective paper and black electrical tape.
  7. Make any necessary repairs to your wiring.


Each group must turn in a summary of all of their test results. Keep individual copies as well. You will find these results, especially the light sensor results, useful in future labs.

This lab must be completed by Monday, September 22 at 10:00 PM.