ES.293 | Spring 2007 | Undergraduate
Lego Robotics


Code Snippets

The following files contain simple scripts that may be helpful in writing Interactive C programs.


bkandfd: menu program that oscillates motor 3 smoothly between full forward and backward (C)

both: turn on two motors at once (C)

bumper: control motor power with the knob (C)

claw1: open a claw, using a sensor to check when it’s fully open (C)

hbexpl: while start_button, use knob to control motor 3; while stop_botton, use knob to control beeper (C)

irtest: demo ir input (C)

musictmpl: play music with the handyboard, within template (C)

parallel: example of multiple processes (C)

sample: very simple example of using switches to control a robot (C)

slow: show how to use the buttons and knobs to control a motor (C)

sup: show all speeds of a motor (C)

Robot Controllers

arm.chad: example hand and arm control logic (C)

cart: robot with front, back, and side sensors, two drive motors and a claw (C)

circles: draw circles on a plotter (C)

claw.alexis: logic for opening a claw fully or a given amount (C)

fencing: spring-simulation fencing controller (C)

ghost: maze robot control, robot bounces off and follow walls (C)

hand: grasping hand with a breakbeam sensor (C)

legoprog: controller for a claw robot that removes objects from its path (C)

line: line-following robot with two downward-facing reflectance sensors (C)

pneum: simple user-controlled claw robot (C)

steer: simple handyboard control for a “turn right or left” steering robot (C)

video: use libraries to process video to identify the locations of two robots on a board (C)


legocomp: base code for a two-team IR competition (C)

melee: output ir codes for helping two teamed robots battle (C)

rec-ir: use an IR communication system to tell two robots about eachother’s position (C)


claw: control a class with a TV remote control, or with four potentiometers (C)

feedback: control a servo motor with different kinds of feedback (C)

music: incomplete re-work of the handyboard music system (C)

read-ir: record values from the IR sensor and print them (C)

svtest1: use the sv library to capture (C)

switchboard: control four motors with four potentiometers (C)

template: control all operations of the handyboard with a menu system (C)

hbirtest: tool to read IR data and report basic statistics (C)

varymot: use the knob to control the power to motor (C)