Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Syntax & Programs / Re: RGB lamp problem on: January 23, 2011, 05:40:27 pm
@raron, I did use 100 ohm resistors on each pin of the led except for the common cathode.
@pauls, thank u for ur advice, but I don't have my arduino with me now. I will try it as soon as I can, and post whether it worked on this forum.
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: RGB lamp problem on: January 23, 2011, 12:37:57 pm
@AWOL, sorry I didn't include what the debug input looks like, it looks like this:
r = 564 g = 227 b = 218
r = 564 g = 227 b = 215
r = 564 g = 228 b = 217
and goes on and on and on.(this is in the serial monitor window in
the Arduino development environment)
The part where the pot data gets sent through the serial connection seems to be working. The LED doesn't light up at all, even if I turn the knobs.
3  Forum 2005-2010 (read only) / Syntax & Programs / RGB lamp problem on: January 23, 2011, 11:34:01 am
I am trying to make a RGB color lamp with pots to control the color.
It doesn't work, and can anyone help me?
/* RGB light attempt
Andrew p.(my mom won't let my put my last name on anything.)

so far this program doesn't work, 
but I am going to comment it anyway so that I can try to fix
it(i wrote it then remembered to comment.)
so i wanted to make a rgb color lamp with user-selectable color, 
and I thought i should use potentiometers.
so i connected 3 5k pots to analog pins 0, 1, and 2(with the other
2 leads connected to 5v and gnd, so that couldn't be the problem).
I connected a rgb led to digital pins 9, 10, adn 11(they are the 
ones with pwm on my arduino.)and i put the gnd pin to ground.
by the way, I'm using a deumilanove. I have a tragic history of 
buying a gadget and then a few weeks later the company comes out 
with a newer, better one. 
so of course Arduino came out with the Arduino uno a few weeks 
after I bought my deumilanove. smiley-cry
anyway, I'll stop rambling and comment the sketch.
i was just commenting the serial connection and i realized i 
forgot to mention that I'm sending the data to the serial port too
for debugging.
before this i sent to pot values to the serial port only, and that
worked, so it's probably the mapping and led pwming that's the 
this is my first major attempt at programming anything more than
a blink program and im only 12.
int pot_red = 0;   //variables for storing the pot data.
int pot_green = 0; //red, green, and blue since it's a rgb lamp.
int pot_blue = 0;  //and set them at zero so the led doesn't
                   //flicker at the beggining of the sketch.

void setup()
  Serial.begin(9600); //begin the serial connection
void loop()
  pot_red = analogRead(0);   // read the 3 pots
  pot_green = analogRead(1); //and store the data in
  pot_blue = analogRead(2);  //each pot's var.
  Serial.print("r = ");  //print the pot values to the serial
  Serial.print(pot_red); //connection. earlier i did just this
  Serial.print(" g = "); //not the led output and mapping part,
  Serial.print(pot_green);//so that is probably the problem.
  Serial.print(" b = ");
  map(pot_red, 0, 1023, 0, 255);//map the pot values to inputs
  map(pot_green, 0, 1023, 0, 255);//for the pwm control.
  map(pot_blue, 0, 1023, 0, 255);
  analogWrite(9, pot_red);  //write the color values to the pwm.
  analogWrite(10, pot_green);//I've never done pwm before,
  analogWrite(11, pot_blue);//so im probably getting pwned by pwm.
  delay(200); //delay to let everything get caught up

Pages: [1]