I’ve been working with the colour module, and now have it reliably detecting 4 different Lego coloured balls. I’ve devised a small cradle to hold the balls while they are being scanned, and use four different methods of displaying the result.
- the colour is printed on the Raspberry Pi monitor
- the colour name is scrolled as a message across the matrix screen
- the rainbow leds are set as near as possible to the colour
- a sound .wav file is played which announces the colour
The program is written in the Sniff language which supports flotilla
A video of the project in action is on youtube here
The Sniff rainbow module uses Hue and Brightness as its two inputs to the hardware, so the program calculates the HLS values from the scanned RGB values and determines the best match to decide upon the colour.
It seems quite reliable. In order to get consistent results the cradle holds the balls in a fixed position in relation to the sensor.