The color sensor is an external device that is connected to the hub through a port. The color sensor is a unidirectional sensor that measures the intensity and rgb value of reflected light.
integer
None
1
2
3
use Libraries.Robots.Spike.ColorSensor
ColorSensor cs
integer port = cs:GetPort()
None
integerport
The port that this color sensor object will be set to
1
2
3
4
5
use Libraries.Robots.Spike.ColorSensor
use Libraries.Robots.Spike.Port
ColorSensor cs
Port port
cs:SetPort(port:A)
integer
None
1
2
3
4
5
6
7
8
9
10
11
12
use Libraries.Robots.Spike.ColorSensor
use Libraries.Robots.Spike.Color
use Libraries.Robots.Spike.Port
use Libraries.Robots.Spike.LightMatrix
ColorSensor cs
Color color
LighMatrix lights
Port port
cs:SetPort(port:A)
if cs:GetColorInteger = color:RED
lights:Write("Red Detected!")
end
integer
None
1
2
3
4
5
6
use Libraries.Robots.Spike.ColorSensor
use Libraries.Robots.Spike.Port
ColorSensor cs
Port port
cs:SetPort(port:A)
integer intensity = cs:GetReflection()
Array<integer>
None
1
2
3
4
5
6
7
8
use Libraries.Robots.Spike.ColorSensor
use Libraries.Robots.Spike.Port
use Libraries.Containers.Array
ColorSensor cs
Port port
Array<integer> rgbi
cs:SetPort(port:A)
rgbi = cs:GetRGBI()