To create a Switch object, the syntax is the following :
mySwitchObject = Switch.new(myPort);
where myPort can be 1, 2, 3 or 4.
In Tribot.u the switch is used as a bumper plugged on the port 4 so the instancing is :
bumper = Switch.new(4);
UltraSonicSensor objects are created the same way:
myUSSObject = UltraSonicSensor.new(myPort);
myPort can be 1, 2, 3 or 4.
In TriBot.u an ultrasonic sensor is connected on port 2:
sonar = UltraSonicSensor.new(2);
The SoundSensor object has an additional parameter:
mySoundObject = SoundSensor.new(myPort, myMode);
myPort can be 1, 2, 3 or 4.
myMode sets the mode of the sensor. It can
be "DB" or "DBA", meaning
"decibel" or "decibel adjusted" (the last one records sounds in
the frequency range 200-14000Hz).
In TriBot.u, the sound sensor is on port 1
using decibel adjusted:
decibel = SoundSensor.new(1,"DBA");
LightSensor also has two parameters :
myLightObject = LightSensor.new(myPort, myMode);
myPort can be 1, 2, 3 or
4. myMode sets the sensor mode and it can
be "Ambiant" (so the sensor measures the
ambiant light), "Reflector" (the sensor lights
on its led and measures the reflected light)
and "Normal" (the sensor returns its raw
value).
In TriBot.u, the light sensor is in reflector
mode on port 1 :
light = LightSensor.new(3,"Reflector");