Discrete RGB colour sensor using a colour LED flashing at high speed and a monochrome LDR (light dependent resistor) for detecting the colour via ADC conversion. The library implements interrupt driven ADC conversion at high speed (370 RGB readings per second, 128 times oversampling per channelfor noise reduction). The detection can optionally run in background.

Dependents:   rgb_sensor_buffer discrete_rgb_color_sensor_example

Revision:
5:1fed2b68e661
Parent:
3:50e1ac3c56db
Child:
6:fc64a14a2f4a
--- a/rgb_sensor.h	Fri Jun 27 12:14:36 2014 +0000
+++ b/rgb_sensor.h	Sat Jun 28 06:59:51 2014 +0000
@@ -62,8 +62,10 @@
       bool m_done;
       uint8_t m_adc_channel, m_rgb_channel;
       DigitalOut m_red, m_green, m_blue;
+      int m_adc_filter[RGB_CHANNELS][2], m_adc_filter_pos;
       int m_adc_aggregation[RGB_CHANNELS], m_adc_count;
       void convert(TRGB &rgb);
+      int filter(int sample);
     private:
       static void __adc_irq(void);
       void adc_irq(void);