Computer Science 014 |
Lecture 2: The Handy Board, The Robot Base, Interactive C
Date: January 4, 2007
Today's lecture location: TCL 206
fd(0); | turns motor 0 on in the forward direction at full power | |
fd(1); | turns motor 1 on in the forward direction at full power | |
fd(2); | turns motor 2 on in the forward direction at full power | |
fd(3); | turns motor 3 on in the forward direction at full power | |
bk(0); | turns motor 0 on in the backward direction at full power | |
bk(1); | turns motor 1 on in the backward direction at full power | |
bk(2); | turns motor 2 on in the backward direction at full power | |
bk(3); | turns motor 3 on in the backward direction at full power | |
motor(0, 50); | turns motor 0 on in the forward direction with a power level of 50% | |
motor(3, -10); | turns motor 3 on in the backward direction with a power level of 10% | |
motor(m, s); | where m is the name of the motor and s is the power | |
motor(m, s)
can be used either to turn the motor on at
a specific level of power or can be used to change the level of
power once the motor is running
off(0); | shuts off motor 0 | |
off(1); | shuts off motor 1 | |
off(2); | shuts off motor 2 | |
off(3); | shuts off motor 3 | |
alloff(); or ao(); | shuts off all motors | |
digital(11)
gives the value of the digital sensor
connected to port 11. So if a touch sensor is connected to that
port:
analog(0)
gives the value of sensor port 0. It
returns a value between 0 and 255. For example, if a photocell
is attached to port 0, might return
start_button()
gives the state of the start button on the Handyboard
stop_button()
gives the state of the stop button on the Handyboard