Please enable JavaScript.
Coggle requires JavaScript to display documents.
Sensors (Color Sensor Setup (note: (modes: (Light Ambient. Turns off all…
Sensors
Color Sensor Setup
brick.SetColorMode(SensorPort, mode);
- Connect the Light Sensor to one of the numbered ports on your LEGO Brick
note:
-
-
modes:
- Light Ambient. Turns off all LEDs and gives a single number representing the amount of
light present in front of the sensor.
- Color Code. Turns on all LEDs and gives a single number representing a color as a coded
number.
- Invalid mode. Do not use.
- Color RGB. Turns on all LEDs and gives 3 numbers, each representing the brightness of
Red, Green, and Blue reflected light.
- Light Reflect.Turns on Red LED and gives a single number representing the amount of reflected light.
- always set the mode before retrieving the sensor value
example, to retrieve the reflected
brightness value of the sensor on port 2
brick.SetColorMode(2, 0);
brightness = brick.LightReflect(2);
-
light reflect function
-
-
Returns the brightness of reflected light in front of the sensor, as a positive integer between 0 and 255. 0 is dark, 255 is bright.
-
color code
Returns the color of an object in front of the sensor, as an integer between 0 and 7:
-
0 = no color, 1 = black, 2 = blue, 3 = green, 4 = yellow, 5 = red, 6 = white, 7 = brown
light ambient function
Returns the brightness of ambient light in front of the sensor, as a positive integer between 0 and 255. 0 is dark, 255 is bright.
-
ColorRGB
Returns the color of an object in front of the sensor, as a row vector of red, green, and blue values of reflected light.
-
TouchPressed
-
Returns 1 if the touch sensor connected to SensorPort is being pressed, and 0 otherwise.
Touch Bumps
-
Returns how many times a touch sensor has been bumped (pressed, then released) since the last brick reset as a positive integer.
-
Sensors allow our robots to interact with the world by measuring physical events and translating them
into digital quantities