Go Down

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

Jel111

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

davidlrf

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

David

davidlrf

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?

Tostitos

#18
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.

newgottland

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.  :)








majipanta

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

burcualici

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!

Go Up