Go Down

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

lou61166

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

Grumpy_Mike

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

jaspercmc

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.

sh_aks

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

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!

jshaddy

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.

SwampFalc

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.

GlynTutt

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.

roberto03

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!

dannable

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

roberto03

Post your code?
Exactly as the p04 from the "Examples" in Arduino's IDE.

dannable

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.
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

roberto03

#12
Jan 19, 2016, 05:04 pm Last Edit: Jan 19, 2016, 05:40 pm by roberto03 Reason: fixing code posting
Of course, here's the code.
Thanks for help.


Code: [Select]

/*
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);
}


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.

Or one of the parts is defective?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

roberto03

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

Go Up