Need help for a program.

Hello, I need help for an arduino program with leds and RGB leds, I already have the program for leds but I would like to launch the program with a remote control (or if it is not possible to switch on the leds). Thanks !
(I have 2 leds RGB and 10 led normal plug in the output 2)

#include "IRremote.h"
int receiver = 12; 
IRrecv irrecv(receiver);   
decode_results results;
// define pins
#define BLUE 3
#define BLUEE 9
#define GREEN 5
#define GREENN 10
#define RED 6
#define REDD 11

void setup()
{
  irrecv.enableIRIn();
  pinMode(2, OUTPUT);
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
  digitalWrite(RED, HIGH);
  digitalWrite(GREEN, LOW);
  digitalWrite(BLUE, LOW);
  pinMode(REDD, OUTPUT);
  pinMode(GREENN, OUTPUT);
  pinMode(BLUEE, OUTPUT);
  digitalWrite(REDD, HIGH);
  digitalWrite(GREENN, LOW);
  digitalWrite(BLUEE, LOW);
}

// define variables
int redValue;
int greenValue;
int blueValue;
int reddValue;
int greennValue;
int blueeValue;

// main loop
void loop()
{
 digitalWrite(2, HIGH);
 delay(200);
 digitalWrite(2, LOW);
 delay(10); 
#define delayTime 1 // fading time between colors

  redValue = 255; // choose a value between 1 and 255 to change the color.
  greenValue = 0;
  blueValue = 0;
    reddValue = 255; // choose a value between 1 and 255 to change the color.
  greennValue = 0;
  blueeValue = 0;

  // this is unnecessary as we've either turned on RED in SETUP
  // or in the previous loop ... regardless, this turns RED off
  // analogWrite(RED, 0);
  // delay(1000);

  for (int i = 0; i < 255; i += 1) // fades out red bring green full when i=255
  {
    redValue -= 1;
    greenValue += 1;
    reddValue -= 1;
    greennValue += 1;
    // The following was reversed, counting in the wrong directions
    // analogWrite(RED, 255 - redValue);
    // analogWrite(GREEN, 255 - greenValue);
    analogWrite(RED, redValue);
    analogWrite(GREEN, greenValue);
    delay(delayTime);
    analogWrite(REDD, redValue);
    analogWrite(GREENN, greenValue);
    delay(delayTime);
  }

  redValue = 0;
  greenValue = 255;
  blueValue = 0;
  reddValue = 0;
  greennValue = 255;
  blueeValue = 0;


  for (int i = 0; i < 255; i += 1) // fades out green bring blue full when i=255
  {
    greenValue -= 1;
    blueValue += 1;
    greennValue -= 1;
    blueeValue += 1;
    // The following was reversed, counting in the wrong directions
    // analogWrite(GREEN, 255 - greenValue);
    // analogWrite(BLUE, 255 - blueValue);
    analogWrite(GREEN, greenValue);
    analogWrite(BLUE, blueValue);
    delay(delayTime);
    analogWrite(GREENN, greenValue);
    analogWrite(BLUEE, blueValue);
    delay(delayTime);
  }

  redValue = 0;
  greenValue = 0;
  blueValue = 255;
  reddValue = 0;
  greennValue = 0;
  blueeValue = 255;

  for (int i = 0; i < 255; i += 1) // fades out blue bring red full when i=255
  {
    // The following code has been rearranged to match the other two similar sections
    blueValue -= 1;
    redValue += 1;
    blueeValue -= 1;
    reddValue += 1;
    // The following was reversed, counting in the wrong directions
    // analogWrite(BLUE, 255 - blueValue);
    // analogWrite(RED, 255 - redValue);
    analogWrite(BLUE, blueValue);
    analogWrite(RED, redValue);
    delay(delayTime);
    analogWrite(BLUEE, blueValue);
    analogWrite(REDD, redValue);
    delay(delayTime);
  }
}

RGB_LED.ino (3.16 KB)

Do you have a particular type of remote control in mind ?

What is the problem, what is the question? Receiving remote, controlling RGB leds, or both?

Please post the code according to the first topics giving advice about that. This way, lots of helpers can't read Your code.

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read

Thanks.. Tom.. :slight_smile:

I upload the code thank you.

UKHeliBob:
Do you have a particular type of remote control in mind ?

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