Can't get the RGB LED to work with the IR Remote

I need help. I've tried coding and testing but nothing works. I want to make it so when you press the POWER button then the RGB LED toggles on or off. If you press 0 then it turns on and the light is white. But no matter what I do the RGB LED doesn't turn on. Here is the code that goes inside the Arduino UNO:
`
// IR remote Library

#include <IRremote.h>

//----Variables-----\

int RedPin = 11;
int GreenPin = 9;
int BluePin = 10;

IRrecv irrecv(12); //Start the IR
decode_results results; //Start the IR
unsigned long key_value = 0;

//-----Start-Once-----\

void setup(){
Serial.begin(9600);

pinMode(BluePin, OUTPUT);
pinMode(RedPin, OUTPUT);
pinMode(GreenPin, OUTPUT);

irrecv.enableIRIn();
irrecv.blink13(true);
}

//-------Repeat-------\

void loop(){
TranslateIR();
}

//------RGB-Colour-----\

void RGBColours(int red, int green, int blue) {
analogWrite(red, red);
analogWrite(green, green);
analogWrite(blue, blue);
}

//-----Translate-IR----\

void TranslateIR() {
if (irrecv.decode(&results)){

    if (results.value == 0XFFFFFFFF)
      results.value = key_value;

    switch(results.value) {
      case 0xFD00FF:	//power
      	Serial.println("POWER");
      	digitalWrite(11, HIGH);
      	digitalWrite(10, HIGH);
      	digitalWrite(9, HIGH);
      	break;
      case 0xFD807F:	//vol+
      	Serial.println("VOL+");
      	break;
      case 0xFD40BF:	//func/stop
      	Serial.println("FUNC/STOP");
      	break;
      case 0xFD20DF:	//|<<
      	Serial.println("|<<");
      	break;
      case 0xFDA05F:	//>||
      	Serial.println(">||");
      	break ;  
      case 0xFD609F:	//>>|
      	Serial.println(">>|");
      	break ;               
      case 0xFD10EF:	//down arrow
      	Serial.println("DOWN ARROW");
      	break ;  
      case 0xFD906F:	//vol-
      	Serial.println("VOL-");
      	break ;  
      case 0xFD50AF:	//up arrow
      	Serial.println("UP ARROW");
      	break ;  
      case 0xFD30CF:	//0
      	Serial.println("0");
      	break ;  
      case 0xFDB04F:	//eq
      	Serial.println("EQ");
      	break ;
      case 0xFD708F:	//st/rept
      	Serial.println("ST/REPT");
      	break ;
      case 0xFD08F7:	//1
      	Serial.println("1");
      	break ;
      case 0xFD8877:	//2
      	Serial.println("2");
      	break ;
      case 0xFD48B7:	//3
      	Serial.println("3");
      	break ;
      case 0xFD28D7:	//4
      	Serial.println("4");
      	break ;
      case 0xFDA857:	//5
      	Serial.println("");
      	break ;
      case 0xFD6897:	//6
      	Serial.println("6");
      	break ;
      case 0xFD18E7:	//7
      	Serial.println("7");
      	break ;
      case 0xFD9867:	//8
      	Serial.println("8");
      	break ;
      case 0xFD58A7:	//9
      	Serial.println("9");
      	break ;
    }
    key_value = results.value;
    irrecv.resume(); 

}
}
`

Here is the circuit:

I am using TinkerCAD to make these circuits.

Do the messages printed make sense? Is it operating at that level, you see the serial stuff but no LED joy?

Have you tested your LED and convinced yourself you have the type you think and have wired correctly for that type?

a7

The serial monitor does print stuff but the LED doesn't turn on.

OK, you have wired the LED as a common cathode.

Take off the wires to 11, 10 and 9 and plug them one by one into 5 volts.

If the LED segments do not light up, you have a common anode LED and you need to wire it differently and code will change a bit also.

Also, just put some code to turn off the LEDs into another received command. I don't see anything in there now that woukd ever turn them off if you e dvr got them to turn on.

Also also this

void RGBColours(int red, int green, int blue) {

function is bogus, good thing you aren't using it yet.

a7

Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

What version of the IRremote library do you have installed?

Hello musman12
Check these lines of code to the port pins use for the RGB Led.

//------RGB-Colour-----\

void RGBColours(int red, int green, int blue) {
analogWrite(red, red);
analogWrite(green, green);
analogWrite(blue, blue);
}

Have a nice day and enjoy coding in C++.
Дайте миру шанс!

ok, I will try and seeing if the wiring works. But i can't think a code that would perform the function that I need. I will have to search that but right now I'm gonna try fix the LED.
In TinkerCAD it says its a cathode:
image

Ok so, I've wired the LED to the 5 V and it works.


So I don't know what the problem is.

So… using your best common sense, get out the blink example, the simplest test program that turns on and off an LED, and apply it to all three of your LEDs what are in one package.

a7

Hello musman12
Take a view to get some ideas.

Have a nice day and enjoy coding in C++.
Дайте миру шанс!

I got it working thank you. Just had to fix couple of bugs in my code!

Please post your working code.

Your observations were misleading… how could it print stuff but and not turn on the LED?

So we wanna see where you landed. What was really the issue?

TIA

a7

The issue was how I wired the LED onto the breadboard. I wired it side ways which wouldn't work.

Haha, no one noticed that in your first image. So now you know more about how breadboards work. :expressionless:

Probably no one who would have caught that even bothered to look closely at the image. Personally, I dislike that way of sharing information.

There is a reason that regular old schematic diagrams, even hand drawn, are preferred! Although in this case, you would just have drawn what you thought you had in front of you, so.

a7

I've got another problem now

Can't find the cause of this thing

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.