Color Sensor TCS34725

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
zackboston
 
Posts: 129
Joined: Mon Feb 25, 2013 12:47 pm

Color Sensor TCS34725

Post by zackboston »

Hello!

Our eek! electronics explorers klub teenagers are building the piano glove for an art + technology activity that explores youth responses to #blacklivesmatter.

While your guide is REALLY great and has easy to follow instructions, I want our youth to understand how the different components actually work at a basic level. So I want to make a little diagram with some explanations.

Unfortunately I tend to learn things on the fly bc I am so busy with keeping our programs going. I've never used a color sensor and know how throughhole RGB LEDs work but don't really understand neopixels and how the signal pin actually works.

Can you direct me to some sources that will help me understand the Color Sensor TCS34725 and the Neopixel and how they communicate with an Arduino (well in our case the Flora)? I don't need all the gory details in terms of the coding, but I just want to get a birds eye understanding the basic flow of data to and from components.

Thanks for any help you can give me!
Susan (Mel is our technology center director, so I put his name on our educator account)

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Color Sensor TCS34725

Post by adafruit_support_bill »

The first couple of pages of the data sheet have some diagrams that show the basic principles of operation: http://www.adafruit.com/datasheets/TCS34725.pdf

Communication with the sensor is via i2c. http://en.wikipedia.org/wiki/I%C2%B2C
The basic idea there is that you have a 'clock' pin (SCL) and a 'data' pin (SDA). The Arduino sends out a series of high and low voltage pulses representing ones and zeros on the data pin, pulsing the clock once for each bit.
Image
With every clock pulse, the sensor reads another bit. When the sensor recognizes the series of bits representing a "Read"command, it responds with a series of bits of its own, representing the Red, Green and Blue data from the sensor.

The Neopixel communication is even simpler - it only has a data pin. The Neopixel has its own internal clock, so the Arduino needs to send the pulses at exactly the speed expected by the pixel. It is not possible to read from the Neopixel, all you can do is send RGB commands to set the red, green and blue levels for the pixel.

If you have more than one pixel connected together, they work like a bucket-brigade. You keep sending RGB commands to the first pixel, and it will pass them along to the next pixel in the chain. When you have sent enough RGB commands for the whole string, you send the "Latch" command. When you send the Latch command, each pixel takes the RGB command it is currently holding and uses that to set the pixel color.

User avatar
zackboston
 
Posts: 129
Joined: Mon Feb 25, 2013 12:47 pm

Re: Color Sensor TCS34725

Post by zackboston »

OK. Let's see if I can translate this right.

You can convert any color into amounts of red + green + blue

HOW THE COLOR SENSOR WORKS:

The color sensor has 4 photocells that provide information about how much
1. clear 2. red 3. green 4. blue are in the color it is "seeing."

There is a little processy thing (RGB Control chip) on the sensor that converts 4 clear/red/green/blue levels into a single COLOR number. This single COLOR number represents the color the sensor is "seeing." This number gets output on the data pin (SDA. . .DA stands for DATA).

How the color sensor works is that there is a clock pin (SCL . . . CL stands for CLOCK) and a data pin (SDA)
The clock pin receives a pulse controlled by the microcomputer on the flora. When the clock pulse is high, the program on the flora takes the COLOR number from the data pin.

HOW THE NEOPIXEL WORKS

The microcomputer inside the FLORA then sends out that COLOR number to the NeoPixel.
The Neopixel has three tiny R + G + B LEDs inside and sets the intensity of each so that together they transmit the right color.

Did I get that right? I want the explanation to be simple, yet pretty close to what actually happens.

Thanks, Susan

User avatar
zackboston
 
Posts: 129
Joined: Mon Feb 25, 2013 12:47 pm

Re: Color Sensor TCS34725

Post by zackboston »

OK. The "levels" of the CRGB on each photocell can be converted to a number that goes from 0 to 255. 0 is all the way turned up. 255 means that color is off.

So the processy RGB control thingie takes the (C, R, G, B) color readings. What does it do with the four 0-255 numbers to convert them to one number?

User avatar
zackboston
 
Posts: 129
Joined: Mon Feb 25, 2013 12:47 pm

Re: Color Sensor TCS34725

Post by zackboston »

Or does the processy (CRGB Control) thingie just transmit the four numbers separately and sequentially during each clock pulse?

Sorry for my ignorance. . . I'm just trying to wrap my mind around this as a kind of hardware newbie. Once I understand this, I can take my beginner code skills and try to figure out the code more easily, so I can explain the different parts to them.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Color Sensor TCS34725

Post by adafruit_support_bill »

OK. The "levels" of the CRGB on each photocell can be converted to a number that goes from 0 to 255. 0 is all the way turned up. 255 means that color is off.
Actually, they are 16-bit values, so they can be 0-65,535.
Or does the processy (CRGB Control) thingie just transmit the four numbers separately and sequentially during each clock pulse?
Yes. All 4 16 bit values are read separately by the Flora. Since they are 16 bits each, it takes 16 clock pulses to transmit each one.

User avatar
zackboston
 
Posts: 129
Joined: Mon Feb 25, 2013 12:47 pm

Re: Color Sensor TCS34725

Post by zackboston »

OK Let's try this again.

The COLOR SENSOR turns the amount of light in each of the photocells, CLEAR, RED, GREEN, BLUE into a 16 bit number (0 - 65835),

The COLOR SENSOR receives a clock signal, like a metronome, from the FLORA and sends one bit back for each "metronome" click.
Each of the CLEAR, RED, GREEN, BLUE levels is represented by 16 bits.
The FLORA receives 16 bits for CLEAR, then 16 bits for RED, etc.

The NeoPixel has an internal "metronome" like clock that is matched up to the FLORA clock.

The FLORA then sequentially sends out the same 4 CLEAR, RED, GREEN, BLUE 16 bit numbers to the NeoPixel (does the NeoPixel have 4 LEDs or only RGB?). The NeoPixel sets the levels on its CRGB LEDs and displays the same color.

Am I getting closer to a fairly close description?

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Color Sensor TCS34725

Post by adafruit_support_bill »

does the NeoPixel have 4 LEDs or only RGB?
The Neopixel has just R, G and B values. These are 8 bit values (0-255), so the Flora has to convert the 16 bit values from the color sensor into 8 bit values for the pixels.

User avatar
zackboston
 
Posts: 129
Joined: Mon Feb 25, 2013 12:47 pm

Re: Color Sensor TCS34725

Post by zackboston »

Oh that really helps! Thanks so much for your patience.

Now the CLEAR number is used by FLORA to adjust for the ambient lighting? The FLORA looks at how dark or light it is in the room where you are using the color sensor and uses it to calculate/adjust the RGB 0-255 values?

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Color Sensor TCS34725

Post by adafruit_support_bill »

Yes. That is an accurate description.

User avatar
zackboston
 
Posts: 129
Joined: Mon Feb 25, 2013 12:47 pm

Re: Color Sensor TCS34725

Post by zackboston »

One more thing. . .

Are the three R, G, B LEDs in the NeoPixel called Pixels?

If so, how are the Pixels different from LEDs?

You can send me a link!

I am going to write this all up on a one page document and make a diagram. Can I send you the explanation and the diagram in the next few days and have you check it out for accuracy?

Thanks so much. If you are ever in Boston, come visit me and I will bake you one of my famous pies. The South End Technology Center @ Tent City is one of the coolest places --- we have the first Fab Lab that was built outside of MIT. I mean it is not as cool as Adafruit, but for a low income community lab in a subsidized housing development that serves mostly urban youth of color, we rock.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Color Sensor TCS34725

Post by adafruit_support_bill »

The R, G and B LEDs are just "LEDs". A "Pixel" is composed of the 3 LEDs. If you post the document & diagram when you are done, I'll be happy to review it.
South End Technology Center @ Tent City
Is that the one near Back-Bay Station? I'll have to stop by the next time I'm in town!

User avatar
zackboston
 
Posts: 129
Joined: Mon Feb 25, 2013 12:47 pm

Re: Color Sensor TCS34725

Post by zackboston »

Thanks.

yes that is right near Back Bay Station. Just before you come, shoot me an email at [email protected] or call at 617.817.2877. I am serious about baking you a pie. you will love mel king and the south end technology center. . . we've got a LOT of HEART!

I really think our youth deserve to have things explained to them in a way they can understand and I am only 1/2 a step ahead of them on this. . . eeek! You were so patient in helping me and you didn't make fun of my ignorance.

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: Color Sensor TCS34725

Post by adafruit_support_bill »

That sounds great Susan. All of us were beginners at some point and teaching is a great way to learn. Even now, with new products in the store every week, we are sometimes only 1/2 step ahead of our customers.

User avatar
zackboston
 
Posts: 129
Joined: Mon Feb 25, 2013 12:47 pm

Re: Color Sensor TCS34725

Post by zackboston »

Thought you all would like to see the fruits of your generous support. Here are our eek! electronics explorers presenting and giving a workshop at the Harvard Graduate School of Education, including the Rainbow Glove and a cool Makey Makey controller for a Sequencer activity. So proud of them. Thanks for your support!

http://goo.gl/wE20R4

Locked
Please be positive and constructive with your questions and comments.

Return to “For Educators”