EGH168 Hands-on Lab






The purpose of this lab is to :

·        Expose your team to some of the sensors that you might use in your robot design.

·        Introduce you to the basic operating principles of microswitches and photo sensors (CdS cells).

·        Familiarize you with  writing and running a program to control the speed and direction of an erector set motor using a microswitch and a CdS cell.

·        Learn how to test the motor ports, analog ports, and digital ports of your handyboard.


Lab Experience

The lab experience will encompass:

1)            Testing the Handy Board ports

2)            Controlling an Erector set motor

3)            Soldering and operating a microswitch, and

4)            Using a Cds (Cadmium Sulfide) cell to control motor.



Lab Experience


Handy Board

Connect the handyboard to the computer using the interface board, phone cable, and serial cable provided.



Interactive C


Run Interactive C on your computer. Follow the instructions to download pcode to your handy board. Select the file Handy_Board_1.2.icd when prompted.


Testing Ports

Determine if your handyboard is working correctly by loading and running the program "hbtest.c". This program will allow you to check the motor ports, analog ports, digital ports, and the control knob. Run the following subroutines (one at a time) by typing them at the bottom of the Interaction Window.

      1. testmotors();
      2. testdigitals();
      3. testanalogs();

Follow the instructions on the handyboard’s LCD screen.


Erector Set Motor


·   Trim a male header strip (use three pins only) and solder it to the wire leads of the erector set motor as indicated on section 6 of the handyboard technical reference.


·   Connect the motor to one of the motor ports. Write a program using the motor(int m, int p) command to turn the motor on and off, and to reverse its direction. Do not exceed a power level of 60~65 (instead of 100). This is to avoid burning the motor (which is rated at 6 V).

·   Use printf statements to show the status of the motor on the LCD screen.



·   Solder a microswitch to a two-wire ribbon cable.

·   Trim a male header strip (use four pins only) and solder it to the other end of the ribbon cable as illustrated in the figures on section 6 of the handyboard technical reference.

·   Connect the microswitch to a digital port.


·   Write a program that allows the motor to run while the microswitch is "not pressed" (switch open). The motor should stop whenever the microswitch is "pressed" (switch closed).

·   Use printf statements to show the status of both the motor and the microswitch on the LCD screen.



Cds (Cadmium Sulfide) Cell

·   Plug a CdS cell directly to an analog port of the handyboard.

·   Write a command to print the output of the CdS cell on the LCD screen.




(Example command:

while(1) printf("%d\n", analog(1)); <enter)

(hit <enter to stop)


·   With the erector set motor, the microswitch, and the CdS cell connected to the handyboard, write a program that will continuously change the speed and direction of the motor based on the output of the CdS cell. Use the start button on the handyboard to run the motor at a maximum power level of 60~65on one direction. As you cover the CdS cell with your hand, the motor will slow down, stop, reverse its direction of rotation, and run at a power level of 60~65. The motor should stop whenever the microswitch is "pressed" (switch closed) or when the stop button is pressed.



Make sure that each team member can operate the handyboard including setup, initialization, connection of devices, operating the devices in command mode, writing code in IC, and operating the devices under program control.







·   Lab reports must be done Individual

·   Follow given lab report format.

·   Maximum 4-5 pages (including figures and tables)



General Guidelines

·   Cover page

·   Description of Experimental Apparatus

·   Description of the lab procedure, problems encountered, and how problems were solved.

·   Include a sketch of the controller, motor, microswitch, and CdS cell connected. Use labels to indicate the ports used.

·   Include copies of the programs used for the microswitch, and the Cds cell exercises.