Go Down

Topic: project 4 color mixing lamp (Read 6528 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?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy