Sensors
| Command | Explanation | Example |
|
activate()
|
Activates the sensor. (You should call setTypeAndMode() before this)
|
Sensor.S1.activate();
|
|
setTypeAndMode (int type, int mode)
|
Sets the type of the sensor and the type of the data.
Recomended values:
| Touch |
setTypeAndMode (1,0x20); |
| Temperature F |
setTypeAndMode (2,0xC0); |
| Temperature C |
setTypeAndMode (2,0xA0);
|
| Light |
setTypeAndMode (3,0x80); |
| Rotational |
setTypeAndMode (4,0xE0); |
|
Sensor.S1.setTypeAndMode(1,0x20);
|
|
readBooleanValue()
|
Reads a true or false from the sensor. (Most often used with touch sensors)
|
Sensor.S1.readBooleanValue();
|
|
readRawValue()
|
Reads the value the sensor is reading. This should be the type of number you set using setTypeAndMode
|
Sensor.S2.readRawValue();
|
|
WaitFor
| Command | Explanation | Example |
|
push(Sensor)
|
Pauses the program till the touch sensor is pushed in.
|
WaitFor.push(Sensor.S1);
|
|
push(Sensor,int n)
|
Pauses the program till the sensor is pushed n times
|
WaitFor.push(Sensor.S1,2);
|
|
release(Sensor)
|
Pauses the program till the touch sensor is released
|
WaitFor.release(Sensor.S2);
|
|
release(Sensor, int n)
|
Pauses the program till the touch sensor has been released n times
|
WaitFor.release(Sensor.S3,2);
|
|
brighter(Sensor, int divider)
|
Pauses the program until the sensor reads a number larger than the divider.
|
WaitFor.brighter(Sensor.S2,40);
|
|
darker(Sensor, int divider)
|
Pauses the program until the sensor reads a number smaller than the divider.
|
Wait.For.darker(Sensor.S3,40);
|
|
Sounds
| Command | Explanation | Example |
|
beep()
|
Makes the robot beep once. The beep is very fast and difficult to hear.
|
Sound.beep();
|
|
beepSequence()
|
beeps a set of downward tones.
|
Sound.beepSequence();
|
|
buzz()
|
makes a low buzz
|
Sound.buzz();
|
|
twoBeeps()
|
Makes two beeps
|
Sound.twoBeeps();
|
|
playTone(int frequency,int durration)
|
plays a note (see below table for frequency/note conversions)
|
Sound.playTone(262,40);
|
|
systemSound(boolean queued,int code)
|
plays a pre-programmed sound. See below for a list of sounds.
|
Sound.system.Sound(true, 1);
|
|
Sounds:
| Code | Sound |
|
0
|
short beep
|
|
1
|
double beep
|
|
2
|
descending arpeggio
|
|
3
|
ascending arpeggio
|
|
4
|
long, low beep
|
|
5
|
quick ascending arpeggio
|
|
Notes:
| Note |
Command |
| C |
Sound.playTone(262,40) |
| C# |
Sound.playTone(277,40) |
| D |
Sound.playTone(294,40) |
| D# |
Sound.playTone(311,40) |
| E |
Sound.playTone(330,40) |
| F |
Sound.playTone(349,40) |
| F# |
Sound.playTone(370,40) |
| G |
Sound.playTone(392,40) |
| G# |
Sound.playTone(415,40) |
| A |
Sound.playTone(440,40) |
| A# |
Sound.playTone(466,40) |
| B |
Sound.playTone(494,40) |
|