Created
January 11, 2024 15:41
-
-
Save topshed/6b59f39508dcc527c5552e7f02bf9e9f to your computer and use it in GitHub Desktop.
Detecting Colour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using the colour sensor, you can detect a range of colours and how much light is reflected from an object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Detecting colours
Add a colour sensor to your robot. If you're building a line following robot, then it needs to be pointing at the floor as shown below.
Otherwise, mount it facing forwards.
Move forward but stop if you're over something red.
Black vs white
Detecting black/white can be trickier, depending on the lighting conditions, and if the black object is quite shiny. This is the most reliable method: the hub will display W if the sensor sees something white, and B if it sees something black.
NEXT: Line following