Color Sensing

Using a sensor on a moving object is tricky because you have to build it in a loop to keep checking the sensor. In this exercise, we’ll make code to loop through color value checking and stop when we hit the black square.

It looks like this:

The setup for checking colored squares on the floor.

The trickiest thing about the color sensor is that it may not see colors the way that humans do. For example, shiny paper of any color may appear white. My tan floor appears blue to the sensor. And so on … I would advise that you find squares of paper to put under Jimmy-Kyle to see what the sensor sees. Just click on the cog on the top right of the Gigabot dashboard to bring up the tools.

Color sensor value

There you can test to see what Jimmy-Kyle sees.

If you have found your color pieces that work, try playing around with the code above and see what you can come up with! The above code will run something like this:

Stop on black #jimmykyle #lanestem

A post shared by Nikole Gipps (@websupergirl) on

Fun question: If you pick up Jimmy-Kyle at the stop, do the motors keep going? Why? Does the motor stop stop the program, or just pause it? How would you stop the program entirely?

Leave a Reply

Your email address will not be published. Required fields are marked *