If you’re like me and are the proud owner of a small room, also known as the Lego Lair, you may find that the lighting conditions in said room sometimes leave a lot to be desired.  You may not really notice this until you start using a sensor that uses light to do its thing.

Take the NXTCam for example.  It’s a great sensor but it doesn’t work so well under bad light.  Everything comes out as shades of grey. You can adjust your colour maps as much as you like, but it won’t make a difference; you either end up not seeing anything at all or the entire world ends up being a single detected blob.

CIMG1303

The latest ROBOTC beta (2.16.1) now sports support for the Lego NXT 2.0 colour sensor which can be used as a source of light as well.  I added two lights to my new robot, they shine on the ground where the red line runs.  I chose to use green light because it turns the red nicely black as far as the NXTCam is concerned. 

CIMG1305 2rfug5j[1] CIMG1304
Bad ambient light, line is detected. The NXT’s view in Line Tracking mode. Brighter ambient light, line is still detected.

The camera can see the line much more clearly.  If you are using a different colour line, you may need to experiment with either red, green or blue.  Make sure you configure the camera’s colour map with the light sensors shining on your target.  I found that configuring the sensor as RBG (white), greatly reduces the amount of light coming from it barely made a difference to what the camera could detect.  The primary colours are by far the brightest options.

So how do you configure the sensor as either a red, green or blue light?  Easy peasy; just download the latest ROBOTC beta from here: [LINK], and use the Motor and Sensor Wizard to configure the appropriate ports as LEGO Color-RGB (for white), Color-Red, Color-Green or Color-Blue.

161116w[1]

Use Color-Ambient to turn the light off but then you may as well not configure the sensor at all.

So there you have it; not much of a hack but a rather simple trick to make your NXTCam work, even under poorer lighting conditions.