Microworlds Library Command Reference
by Arnan (Roger) Sipitakiat
arnans@media.mit.edu
Sensor Commands:
|
sensor1 |
Read the sensor value. Value ranges between 0-1023.
|
|||
|
switch1 |
Returns the ON/OFF status of the sensor. This
command is simply a macro that returns
|
|||
|
Examples |
will show sensor1's value
will move the current turtle 100 steps if switch1 is ON.
will pause the program until switch3 is OFF. |
|||
|
sensorMax1 |
Returns the maximum sensor reading the board has
detected since the last sensorMax operation.
The GoGo board automatically stores the highest sensor value it detects on each sensor port. It will send and reset this value of sensor port N every time a sensorMaxN command is used, where N ranges between 1 to 8. This function is very useful especially when the sensor is activated for a very short time (such as a push button used in a game). In this case, detecting the change by polling the sensor from Microworlds is often not quick enough. This is where sensorMax becomes very handy. |
|||
|
sensorMin1 |
Same idea as sensorMax but returns the minimum sensor value the board has detected since the previous sensorMin operation. |
Output Commands:
|
tta |
Talk to an output port. This command will set the corresponding port at the active port. It will be the port effected by the action commands below. | ||
|
TalkToPort [Port-list] |
Talk to
multiple output ports. Use this command when you want to control
multiple devices simultaneously.
Port-list consists of a list of port names ranging from 'a' to 'f' |
||
|
Examples |
will set port a, b, and c as the active ports.
will set port a, b, c, and f as the active ports (notice that port order has no effect) |
||
|
On |
Turns on the power of the active port(s). | ||
|
Off |
Turns off
the power of the active port(s).
Note: Off is actually a macro that calls Break (see below) and wait for a short time then calls Coast. It does this to save battery power. |
||
|
Coast |
Turns off the power of the active port(s). When attached to motors, no breaking is applied. Thus, the motor will gradually slow down before stopping completely. | ||
|
Break |
When used
with motors, Break will immediately stop the motors (see Coast).
Note: the break command draw a lot more energy from the battery than Coast and Break. It continues to consume power even though the motors have stopped. Thus, use it with care. |
||
|
OnFor Duration |
Turns on the active port for a Duration of time. Duration is in tenth of a second. | ||
|
Examples |
will turn on port A for 1 second. This is the equivalent of:
|
||
|
Thisway Thatway |
When used
with motors, these two commands controls the direction in which the
motor turns.
Thisway and Tahtway could mean clockwise or counter-colckwise depending on how the motors are plugged into the port. |
||
|
Rd |
Rd reverses the direction of the motor. | ||
|
SetPower Power |
Sets the
power level of the active port.
Power ranges between 0-7. The default power level is 7 (full power). |
||
|
Examples |
will lower the power of all output ports by half of the full power. |
