ColorSensor
Example
// Initialize the Color Sensor
var color = new serviceSPIKE.ColorSensor("E")
Methods
-
inner get_color() → {string}
-
Get the name of the detected color
Returns:
string -'black','violet','blue','cyan','green','yellow','red','white'
-
inner get_reflected_light() → {number}
-
Retrieves the intensity of the reflected light.
Returns:
number -The reflected light intensity. [0 to 100]
-
inner get_red() → {number}
-
Retrieves the red color intensity.
Returns:
number -[0 to 1024]
-
inner get_green() → {number}
-
Retrieves the green color intensity.
Returns:
number -[0 to 1024]
-
inner get_blue() → {number}
-
Retrieves the blue color intensity.
Returns:
number -[0 to 1024]
-
inner wait_until_color(colorInput, callback)
-
Waits until the Color Sensor detects the specified color.
Parameters:
Name Type Description colorInput
string 'black','violet','blue','cyan','green','yellow','red','white'
callback
function callback function
-
inner wait_for_new_color(callback)
-
Execute callback when Color Sensor detects a new color. The first time this method is called, it returns immediately the detected color. After that, it waits until the Color Sensor detects a color that is different from the color that was detected the last time this method was used.
Parameters:
Name Type Description callback
function params: detected new color