IR signals controlling tri color LED

I had this idea to hook up an IR universal TV/DVD/VCR remote control into something that can control my computer or send MIDI data to my computer...

for now i just want to test out the idea by controlling a tri color LED with the remote.

I made this shield for my project... Its got 5v hooked up to an IR reciever, with the output going to digital pin 11, and the ground from the IR reciever going to ground on arduino.

I've also got a tri color LED hooked up, from pins 3, 5, and 6 with 330 ohm resistors leading up to the RGB pins on the tri color LED. and i've got the LED grounded to the same ground as the IR receiver...

NOW THEN... I've coded the following sketch for my arduino to work with my shield, but for some reason, when i run the code my IR reciever work fine but the LED doesn't light up at all...

its just strange because when i hook up the 5v and ground pins to the wrong ports on the arduino, it will work... like if rather than hooking it up correctly to the 5v and ground, i hook it up to 3.3v and 5v... for whatever reason, even though it's not grounded, it will make it so that the LED works but not the IR receiver... strange... i can't get one working without the other one not working...

here are some pictures of my shield, and the code i am using right now to try to light up the LED...

/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int lightX = 0;
int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  digitalWrite(3, HIGH);
  digitalWrite(5, LOW);
}

void loop() {
  digitalWrite(3, HIGH);
  digitalWrite(5, LOW);
  if (irrecv.decode(&results)) {
    digitalWrite(3, LOW);
    digitalWrite(5, HIGH);
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

if anybody can help me figure out why this isn't working please let me know... I really appreciate all the help i've gotten from this forum so far, its been a great place to learn.

Hi

Is it possible you have a common-anode RGB LED there (like this Diffused RGB (tri-color) LED [Common Anode] : ID 159 : $2.00 : Adafruit Industries, Unique & fun DIY electronics and kits)?

If so you need to wire it up with the common line running to +5V and setting the pins HIGH actually results in them being off, to turn them on you need to set them LOW. It's hard to tell from your images.

Geoff

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  digitalWrite(3, HIGH);
  digitalWrite(5, LOW);
}

What is attached to pins 3 and 5?
Pins by default are inputs, so all you're doing here is enabling/disabling the built-in pullups.

Gah! Missing pinMode() for the outputs. Well spotted.

Thank you for the suggestions... I thought it might be that i didn't put the pinMode as output for 3,5,and 6... I changed the code to this...

/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int lightX = 0;
int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(11, INPUT);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  digitalWrite(3, HIGH);
  digitalWrite(5, LOW);
}

void loop() {
  digitalWrite(3, HIGH);
  digitalWrite(5, LOW);
  if (irrecv.decode(&results)) {
    digitalWrite(3, LOW);
    digitalWrite(5, HIGH);
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

when i changed the code, the IR receiver still works, but the LED still doesn't light up... I'm beginning to think that it IS a common anode LED... in which case, i should be able to just resolder the LED to be hooked up to 5 Volt current, rather than the ground... that would also explain why the light works when i hook it up 'wrong' to the 3.3v and 5v pins.

I will try to resolder my shield and see if that fixes it.

THANK YOU.

Stop, forget the IR rx, and just write a very simple sketch to turn the LEDs on and off, using serial debug if necessary to tell you what you're writing to them.

i found out that it IS a common anode type RBG LED... so i had to resolder the wires to reflect this... I've got the common anode hooked up to the 5v, rather than ground... and I've reprogrammed my code to reflect this, by changeing the values from HIGH to LOW, in respect to the desired effect i'm looking for... here is the new code...

/*
 * IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
 * An IR detector/demodulator must be connected to the input RECV_PIN.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

#include <IRremote.h>

int lightX = 0;
int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(11, INPUT);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  digitalWrite(3, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
}

void loop() {
  digitalWrite(3, LOW);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  if (irrecv.decode(&results)) {
    digitalWrite(3, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, LOW);   
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

and it works GREAT! thanks for your help...

Thanks for keeping us up-to date.

Maybe think about giving those pins names..?

AWOL:
Thanks for keeping us up-to date.

Maybe think about giving those pins names..?

thanks for the suggestion on good coding etiquette. I will do that.

Next up, i'm planning on combining this code with some other code this forum helped me out with a while back, and turn this remote control into a MIDI controller...

I think I'll leave this thread here where it lies, and pick up my old thread on the remote control MIDI remote, and start getting things going there.
here is the link to that thread... http://arduino.cc/forum/index.php/topic,81699.0.html

again, thanks everyone for all your help, this forum is AMAZING...