Skip to main content

Color Sensor

Back to article list

Color Sensor


Programming Blocks

Block Function
It will return the color sensor value, the number is lower on white surfaces and increases as the surface gets darker.
It will compare the sensor value with the set value and return a logic (true/false) result.

Electrical characteristics

Specification Value
Weight 6.8 g / 7.7 g with flat plugs
Supply voltage 6–10 VDC
Current consumption approx. 15 mA
Signal Analogue value 0–2 VDC (output in mV)
Red wire 9 VDC
Green wire Ground
Black wire Signal

Dimensions


Sample Code

Result: The returning value of the sensor will be shown on the display.


P Controller Line Follower

Hardware Connection: connect the motors and sensors as the sample robot instructions which can
be found at:
https://fiproductmedia.azureedge.net/media/Marketing%20Materials/Operating%20instructions/BA_576109_STEM-CODING-ROBO-MISSION-VERSION-2.pdf

Result: The robot can follow a line smoothly.

Note: The factor of the P controller is 0.2 in this code, which can be adjusted based on robot
performance. Also, the speed of the line following is 400.