Module with 4 white LED based on the TAOS TCS230 chip, a color light-frequency converter. The sensor is composed of 16 photodiodes with blue filters, green filters, red filters and unfiltered.
All the photodiodes of the same color are connected in parallel. When an object is placed in front of the module, at a distance of not more than 10 cm, it is illuminated by 4 white LEDs and the reflected light will hit the 64 photodiodes, resulting in a square wave output (Duty cycle 50%) with a frequency directly proportional to the intensity of the reflected light. The full scale output frequency can be adjusted to one of three preset values available via two control input pins. The full scale output frequency can be adjusted to one of three preset values available via two control input pins. The digital inputs and digital output allows you to interface directly to the Arduino or other logic circuits. The pins S2 and S3 are used to select which group of photodiodes (red, green, blue, clear) are active.
Features
- High-Resolution Conversion of Light Intensity to Frequency
- Programmable Color and Full-Scale Output Frequency
- Communicates Directly With a Microcontroller
- Single-Supply Operation (2.7 V to 5.5 V)
- Power Down Feature
- Nonlinearity Error Typically 0.2% at 50 kHz
- Stable 200 ppm/°C Temperature Coefficient
- Low-Profile Surface-Mount Package
Example code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
/* // TCS230 color recognition sensor // Sensor connection pins to Arduino are shown in comments Color Sensor Arduino ----------- -------- VCC 5V GND GND s0 8 s1 9 s2 12 s3 11 OUT 10 OE GND */ const int s0 = 8; const int s1 = 9; const int s2 = 12; const int s3 = 11; const int out = 10; // LED pins connected to Arduino int redLed = 2; int greenLed = 3; int blueLed = 4; // Variables int red = 0; int green = 0; int blue = 0; void setup() { Serial.begin(9600); pinMode(s0, OUTPUT); pinMode(s1, OUTPUT); pinMode(s2, OUTPUT); pinMode(s3, OUTPUT); pinMode(out, INPUT); pinMode(redLed, OUTPUT); pinMode(greenLed, OUTPUT); pinMode(blueLed, OUTPUT); digitalWrite(s0, HIGH); digitalWrite(s1, HIGH); } void loop() { color(); Serial.print("R Intensity:"); Serial.print(red, DEC); Serial.print(" G Intensity: "); Serial.print(green, DEC); Serial.print(" B Intensity : "); Serial.print(blue, DEC); //Serial.println(); if (red < blue && red < green && red < 20) { Serial.println(" - (Red Color)"); digitalWrite(redLed, HIGH); // Turn RED LED ON digitalWrite(greenLed, LOW); digitalWrite(blueLed, LOW); } else if (blue < red && blue < green) { Serial.println(" - (Blue Color)"); digitalWrite(redLed, LOW); digitalWrite(greenLed, LOW); digitalWrite(blueLed, HIGH); // Turn BLUE LED ON } else if (green < red && green < blue) { Serial.println(" - (Green Color)"); digitalWrite(redLed, LOW); digitalWrite(greenLed, HIGH); // Turn GREEN LED ON digitalWrite(blueLed, LOW); } else{ Serial.println(); } delay(300); digitalWrite(redLed, LOW); digitalWrite(greenLed, LOW); digitalWrite(blueLed, LOW); } void color() { digitalWrite(s2, LOW); digitalWrite(s3, LOW); //count OUT, pRed, RED red = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH); digitalWrite(s3, HIGH); //count OUT, pBLUE, BLUE blue = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH); digitalWrite(s2, HIGH); //count OUT, pGreen, GREEN green = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH); } |
Reviews
There are no reviews yet.