project 4 color mixing lamp

My starter kit only came with a blue transparent gel, not red or green how can i get them,or use in place off.
Thanks

Candy wrappers.
The ones called "Quality Street" have them.

Excuse me! I'm new here and have a question about this project.
What's the difference between with transparent gel and without it? Will that affect the input of each sensor? Thanks in advance.

What's the difference between with transparent gel and without it? Will that affect the input of each sensor?

The colored gels act as a filter and lets only the light of a specific color to pass through the sensor being covered.
eg.
The red filter passes only red light.

This helps you to detect the relative color levels in the light that hits the sensor.

I suspect I'm a bit late entering this thread - but I'm having difficulties attaching the coloured gels to the photoresistors - the wood-type holders don't fit in a sensible way and tend to slide down the resistor legs. Moreover I don't think there is enough room for them with the resistors placed where they are in the book diagram.Help - if you've managed to complete this project I'd like to know how!

alechk:
I suspect I'm a bit late entering this thread - but I'm having difficulties attaching the coloured gels to the photoresistors - the wood-type holders don't fit in a sensible way and tend to slide down the resistor legs. Moreover I don't think there is enough room for them with the resistors placed where they are in the book diagram.Help - if you've managed to complete this project I'd like to know how!

Thank you for highlighting the wood holders; I was having a hard time figuring out what the gel "holder" was supposed to be based upon Fig. 2 in the project.

I ended up using tape to secure the short "tabs" of the gel that ended up poking through the underside of each side of the wood holders . By taping them, when I slipped them on the resistors, the gel was no longer pushed out of the holder and the holder doesn't slide down the sensor.

And you are right, with the holders slipped over the resistors, the placement cannot be perfectly replicated as shown in Fig. 1. So I have the LED in rows 4-7 of my breadboard (the cathode is in row 5). The photoresistors are in rows 17 (red), 24 (green), 30 (blue), but am realizing even that may be too close as it doesn't allow me to easily direct a light source onto just one sensor, so I may end up spreading them out further. Things seem to be working with this setup (LED lights up and changes color a bit) but I need to tweak things more to get proper color response.

As long as power, ground, resistor, and pin connections are still maintained to the new rows; it shouldn't be a problem to move the resistors further apart.

alechk:
I suspect I'm a bit late entering this thread - but I'm having difficulties attaching the coloured gels to the photoresistors - the wood-type holders don't fit in a sensible way and tend to slide down the resistor legs. Moreover I don't think there is enough room for them with the resistors placed where they are in the book diagram.Help - if you've managed to complete this project I'd like to know how!

I don't know about you, but in my case, the widest dimension of the photoresistor is just a wee bit wider than the smallest dimension of the hole in the holders.

So I put the resistor through all the way, twist it 90 degrees and then gently push it back down into the wood.

But I can totally imagine your wooden holder to be just a little bit bigger.

Either way, I found that the setup as given has some problems.

First of all, the sensors are too close to one another to be able to really control the light of the LED.

And second, the LED itself tends to shine on the sensors.

Maybe an easy hack: find a ballpoint pen (a yellow Bic might be ideal), cut it in 3 hollow poles, make a cut in them ALMOST all the way through. Put the gel into the slot you cut, put the poles over the sensors.

Hello,

I'm working through all of the starter kit experiments with my 12 year old Son and diligently reading the written notes both in the book and in the Program.

Up until this one (setting aside the difficulties with sensor holders and gels which are all solved with a bit of sticky tape and patience) the other examples were pretty easy to follow and understand - i.e. fairly easy to work through all of the program steps and follow what the Arduino and Circuit was doing.

However, this example seems to introduce far too much in one step and I think that the supporting book needs to go into a little more detail what PWM does and how a number between 0 and 255 using the appropriate I/O pins and commands affects the signal.

This background information I have found under the 'resources' section on the website, but when working through the tutorials (especially with my son) it would be nice to have a little bit more of an explanation in the booklet.

The introduction of the LDRs through inclusion in a potentionmeter onto the Analogue Pins is great!, but I think that initially just demonstrating how the 3 colour LED works and then perhaps a fading in and out of the LED by way of a counter routine would make this tutorial into a part A) B) C) type example with the additional value add that would be gained from this more gentle approach.

Good thread. I built the project 04 and when I power it up the light doesn't light up at all.
When I unplug the cable connected to the "blue" photoresistor, then the light becomes blue. Same for the green plug and the red one.

Could you give me any suggestions?

Thanks!

Post your code?

dannable:
Post your code?

Exactly as the p04 from the "Examples" in Arduino's IDE.

I asked for your code. The number of times there is a simple typo is amazing.

However, I'm happy to let someone else come along and assist.

Of course, here's the code.
Thanks for help.

/*
Arduino Starter Kit example
Project 4  - Color Mixing Lamp

This sketch is written to accompany Project 3 in the
Arduino Starter Kit

Parts required:
1 RGB LED 
three 10 kilohm resistors
3 220 ohm resistors
3 photoresistors
red green and blue colored gels

Created 13 September 2012
Modified 14 November 2012
by Scott Fitzgerald
Thanks to Federico Vanzati for improvements

http://arduino.cc/starterKit

This example code is part of the public domain 
*/

const int greenLEDPin = 9;    // LED connected to digital pin 9
const int redLEDPin = 10;     // LED connected to digital pin 10
const int blueLEDPin = 11;    // LED connected to digital pin 11

const int redSensorPin = A0;  // pin with the photoresistor with the red gel 
const int greenSensorPin = A1;   // pin with the photoresistor with the green gel 
const int blueSensorPin = A2;   // pin with the photoresistor with the blue gel 

int redValue = 0; // value to write to the red LED
int greenValue = 0; // value to write to the green LED
int blueValue = 0; // value to write to the blue LED

int redSensorValue = 0; // variable to hold the value from the red sensor 
int greenSensorValue = 0; // variable to hold the value from the green sensor 
int blueSensorValue = 0; // variable to hold the value from the blue sensor 

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600); 

// set the digital pins as outputs
pinMode(greenLEDPin,OUTPUT);
pinMode(redLEDPin,OUTPUT);
pinMode(blueLEDPin,OUTPUT);
}

void loop() {
// Read the sensors first:

// read the value from the red-filtered photoresistor:
redSensorValue = analogRead(redSensorPin);
// give the ADC a moment to settle
delay(5);
// read the value from the green-filtered photoresistor:
greenSensorValue = analogRead(greenSensorPin);
// give the ADC a moment to settle
delay(5);
// read the value from the blue-filtered photoresistor:
blueSensorValue = analogRead(blueSensorPin);  

// print out the values to the serial monitor  
Serial.print("raw sensor Values \t red: ");
Serial.print(redSensorValue);
Serial.print("\t green: ");
Serial.print(greenSensorValue);
Serial.print("\t Blue: ");
Serial.println(blueSensorValue);

/*
In order to use the values from the sensor for the LED, 
you need to do some math. The ADC provides a 10-bit number, 
but analogWrite() uses 8 bits. You'll want to divide your 
sensor readings by 4 to keep them in range of the output. 
*/
redValue = redSensorValue/4;
greenValue = greenSensorValue/4;
blueValue = blueSensorValue/4;  

//  print out the mapped values  
Serial.print("Mapped sensor Values \t red: ");
Serial.print(redValue);
Serial.print("\t green: ");
Serial.print(greenValue);
Serial.print("\t Blue: ");
Serial.println(blueValue); 

/*
Now that you have a usable value, it's time to PWM the LED.
*/
analogWrite(redLEDPin, redValue);
analogWrite(greenLEDPin, greenValue);
analogWrite(blueLEDPin, blueValue);
}

If the code you are using is identical to that in the book then there must be a problem with the way you have wired it up.

Or one of the parts is defective?

dannable:
If the code you are using is identical to that in the book then there must be a problem with the way you have wired it up.

This is the probably the case.

Thanks

@robert03 hey this may not be the issue but i had the same problem. In the code it shows using pins 9-10-11

const int greenLEDPin = 9; // LED connected to digital pin 9
const int redLEDPin = 10; // LED connected to digital pin 10
const int blueLEDPin = 11; // LED connected to digital pin 11

but in the project book your are shown to use pins 3-4-6. Weird that they would change the pins and not update with a comment. Being new and this being the second actual project that is a lot to ask us to figure out. It took like a half hour to realize.

Hi,

I'm having the same problem that Robert03 was having. The LED does not light up, but if I remove any of the resistors that are in series with the photoresistor and ground, the light comes on. The color of the LED depends on which resistor I remove.

One thing that I noticed is that the photoresistors for the project (or at least what I THINK are photoresistors) look like transparent , somewhat rectangular LEDs. The photoresistors I see everywhere else look different. Do all photoresistors look like this Photoresistor - Wikipedia or are there others types?

In case it helps, my code is below:

const int green_led_pin = 9;
 const int red_led_pin = 10;
 const int blue_led_pin = 11;

 const int red_sensor_pin = A0;
 const int green_sensor_pin = A1;
 const int blue_sensor_pin = A2;

 int red_value = 0;
 int blue_value = 0;
 int green_value = 0;

 int red_sensor_value = 0;
 int blue_sensor_value = 0;
 int green_sensor_value = 0;


void setup() 
{
 Serial.begin (9600);
 pinMode (green_led_pin, OUTPUT);  
 pinMode (red_led_pin, OUTPUT);  
 pinMode (blue_led_pin, OUTPUT);  
}

void loop()
{
int red_sensor_value = analogRead (red_sensor_pin);
delay (5);
int green_sensor_value = analogRead (green_sensor_pin);
delay (5);
int blue_sensor_value = analogRead (blue_sensor_pin);

Serial.print ("Raw sensor values:  \t red:  ");
Serial.print (red_sensor_value);
Serial.print ("\t green:  ");
Serial.print (green_sensor_value);
Serial.print ("\t blue:  ");
Serial.println (blue_sensor_value);

red_value = red_sensor_value / 4;
green_value = green_sensor_value / 4;
blue_value = blue_sensor_value / 4;

Serial.print ("Mapped sensor values:  \t red:  ");
Serial.print (red_value);
Serial.print ("\t green:  ");
Serial.print (green_value);
Serial.print ("\t blue:  ");
Serial.println (blue_value);

analogWrite (red_led_pin, red_value);
analogWrite (green_led_pin, green_value);
analogWrite (blue_led_pin, blue_value);
}

Any help is appreciated.

David

I finally got back to working on the project and I think I found my problem, or at least a clue.

If I turn the photoresistors around, so the cathode is on the side with power, everything works fine. Maybe I have something else backwards?

You're not alone, davidlrf, I had the same problem. I couldn't get this project to work either until I turned the photoresistors around so they're backwards compared to the book. I can only assume the wires were cut wrong... for me the short leg is anode, the longer cathode.

And the gels they give you are completely useless, you can't even do what they diagram in the book (using the wooden E pieces)... perhaps they changed the design without updating the book? Edit: discovered this is indeed the case, the LDRs they use now are different.

Yes. I took one look at the gels and the plastic pressboard fixtures and said "nope." So I built a little gel cover with cardboard, hot glue, and tape. Photos below.

As for the circuit. Like others, I got nothing from the LED when I ran the sketch. I just pulled the 220 ohm resisters out and it worked. I've tinkered around with it enough. Moving on. :slight_smile: