Color Sensor

The Color Sensor has 3 internal sensors that detect how much of the light entering it is Red, Green, and Blue.


Testing the Sensor

Start up the Spike software.

Connect your Spike Hub to your Laptop/Tablet via either USB or Bluetooth.

Connect the Color Sensor to one of the Hub's ports.

When you point the Color Sensor at a colorful object you can see your Spike Hub reporting back the result.

Each color has some number code associated with it (like Blue = 3), but it's not an important detail for this course.

Challenge 1 - Recognizing Colors

Let's try to make the Spike Hub prove to us that it can recognize colors. Let's have it perform some distinct function when it recognizes 3 or more different colors:

HINT - You can use Event blocks like this:

Challenge 2 - Stop on

Use some markings on the floor, like a black tape to create a colorful area.

Use your 2-wheel robot, and program tit to drive from any location forward pointing towards the colorful area, and STOP when it detects that color.

NOTE: When you mount the Color Sensor on your robot it is best to have it point straight down, and be roughly one LEGO piece height off the floor.

HINT - You can use Control and Sensor blocks like this:

Challenge 3 - Boxed In

Change the program so that it turns away from color, not just stop. Then put that in a loop and see if your robot can stay Boxed In within some polygon markings on the floor.