Go Down

Topic: project 4 color mixing lamp (Read 28239 times) previous topic - next topic


@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.



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 https://en.wikipedia.org/wiki/Photoresistor#/media/File:LDR_1480405_6_7_HDR_Enhancer_1.jpg or are there others types?

In case it helps, my code is below:

Code: [Select]
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.



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?


Apr 10, 2017, 05:37 am Last Edit: Apr 10, 2017, 05:55 am by Tostitos
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.  :)


Hi. My project works perfectly. Thank you so much. The last thing that I tried was to illuminate the sensors with a flashlight and when I illuminated the blue sensor the LED's color changed to red and vice versa. Do you have the explanation of that result or do you have a link that can help me out to understand? Thanks


Hello everyone, I have done this project and it worked perfectly but I couldn't understand the point in doing the project. Can someone explain why did we put gels on sensors and how did the color of the lamp change accordingly? Thanks so much in advance!


I found this project interesting and I liked the lessons learned in it, but the setup is a real pain. It took me forever to get the gels in place. I ultimately decided that it wasn't worth the time to get the gels just right and proceeded ahead in the name of not getting frustrated at the design.

Overall the code worked as planned and I got the concept of the project. The gel setup is a pain though.


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?

Hi roberto03. I just bought an arduino, and just spent the last 2 hours on exactly the same problem. Turns out I got a faulty breadboard. It seems the "+" line on the right side of the board doesn't run all the way through. This causes no voltage over the photodiode such that it doesn't generate any current.

Go Up