Color
![_images/Color.png](_images/Color.png)
-
class
devices.
Color
(ev3handle, layer=1, portnum=1, inputmode='ambient')[source] The class to represent the EV3 color sensor.
Set up a color sensor on port number 2
>>> from pyev3.brick import LegoEV3 >>> from pyev3.devices import Color >>> myev3 = LegoEV3(commtype='usb') >>> mysensor = Color(myev3, portnum=2, inputmode='rgb')
- Parameters
ev3handle (object) –
LegoEV3
instance representing the EV3 brick.layer (int) – The layer of the brick
1
or2
in a daisy-chain configuration.portnum (int) – The brick input port connected to the sensor. Possible values are
1
,2
,3
, or4
.inputmode (str) –
'ambient'
ambient light intensity'reflected'
reflected light intensity'color'
surface color'rgb'
surface color RGB components
-
display_info
() Displays a summary with the sensor information.
-
property
inputmode
Contains the sensor input mode. Use this to change the mode on the fly (read/write).
-
property
output
Contains the sensor output based on the inputmode (read only).
0
to100
(inputmode=’ambient’)0
to100
(inputmode=’reflected’)'blue'
,'green'
,'yellow'
,'red'
,'white'
,'brown'
,'unknown'
(inputmode=’color’)tuple of integers (
0
to255
,0
to255
,0
to255
) (inputmode=’rgb’)