Pages: [1]   Go Down
Author Topic: Arduino - IR RGB Controller  (Read 655 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi I´m currently trying to rebuild an RGB light stripe controller such as this one


I was already abel rebuild the color functions from the IR Remote
The major problem is still the fade mode. Starting the fade mode is no problem at all but exiting it is a big one as far as i konow the problem is that the loop makes it impossible to read the IR remote code to exit the loop.
I would be really happy if someone could give me an advise or even a bit of code ?

If you need more information please feel free to contact me
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26509
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How can we know what you're missing unless you post your code?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

At the moment I have just the complex code whre all stuff is includet
I thought it would be easyer just to develope the fade sequenze

Code:
#include <TimerOne.h>
#include <IRremote.h>

int RECV_PIN = 11;  // IR-Receiver PIN
int led = 12;       // Satus-LED PIN
int modus;          // Modus for Interrupt-Querry
int ledr = 6;       // RGB LED red PIN
int ledg = 7;       // RGB LED green PIN                       
int ledb = 8;       // RGB LED blue PIN
int SerialBuffer = 0;

int RedVal=1;       // Variablen for fader
int BlueVal=1;      //  "
int GreenVal=1;     //  "
int i=1;            // Counter for fader
int timerwert = 50;   // Timer time for Interrupt in ms
int fadespeed = 10;   // Speed for Fade --> 1: extrem fast
                      //                --> 10: normal
                      //                --> 100: extrem slow
 
String readString;
/////////////////////////////////////////////////////////////////////////////////////

IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
  pinMode(ledr, OUTPUT); // Set RGB LED Pins as Output
  pinMode(ledg, OUTPUT); // Set RGB LED Pins as Output
  pinMode(ledb, OUTPUT); // Set RGB LED Pins as Output
 
  pinMode(led, OUTPUT); // set Status-LED as Output
 
Serial.begin(9600);
 
  irrecv.enableIRIn(); // Start of IR-Recive
     
  Timer1.initialize(timerwert); // Initialisation of Timer-Interrupts
  Timer1.attachInterrupt(leseIR); // IR-Read from Interrupt
}

void leseIR(){
//Permanent Querry if value of IR-Recieve, Althought loop
  if (irrecv.decode(&results)){
    switch (results.value)  {
     
      case 0xFF10EF: // Modus Fade (DIY 4)
        modus = 1; 
      break;
     
      case 0xFF906F: // Modus pcambi (DIY 5)
        modus = 2; 
      break;
     
     
     
      // DIY 1 FF30CF
      // DIY 2 FBB04F
      // DIY 3 FF708F
      // DIY 4 FF10EF
      // DIY 5 FF906F
      // DIY 6 FF50AF
     
      case 0xFF02FD:  //Power
       modus = 0;
       digitalWrite(led, HIGH);   // Status LED ON     
       delay(500);                // Pause 0,5s
       digitalWrite(led, LOW);    // Status LED OFF
       setColor(0, 0, 0);         // RGB LEDs Off
      break;
       
       /////////////////////
       //Standart RGB Remote
       /////////////////////
       
      case 0xFFA25D:  //Blau 0,0,255
        modus = 0;
        setColor(0, 0, 255);
      break;
     
      case 0xFF1AE5: //Rot
        modus = 0;
        setColor(255, 0, 0);
      break;
     
      case 0xFF9A65://Grün
        modus = 0;
        setColor(0, 255, 0);
      break; 
     
      case 0xFF22DD: //Weiss
        modus = 0;
        setColor(255, 255, 255);
      break;
     
      case 0xFF2AD5: //orange
        modus = 0;
        setColor(255, 165, 0);
      break;
     
      case 0xFFAA55://Grün mitrtel
        modus = 0;
        setColor(124, 252, 0);
      break; 
     
      case 0xFF926D: //blau mittel
        modus = 0;
        setColor(92, 172, 238);
      break;
     
      case 0xFF12ED: //rosa
        modus = 0;
        setColor(255, 228, 196);
      break;     
     
     
     }             // Switch END
  }                // Empfange IR END
 irrecv.resume();  // Receive the next value
}                  // Read IR END


void setColor (int red, int green, int blue) {
 // RGB LED: write inverted value for each color
  analogWrite(ledr, 255 - red);
  analogWrite(ledg, 255 - green);
  analogWrite(ledb, 255 - blue);

  delay(1000);
}

   
   
   ///////////////////
   /// Fade //////////
   ///////////////////
   
 void fade(int Speed){
  analogWrite(ledr,255-RedVal);
  analogWrite(ledb,255-BlueVal);
  analogWrite(ledg,255-GreenVal);
 
  RedVal =((i<255)*i)+((i>=255)*255)+((i>511)*(512-i))+((i>766)*(i-766))+((i>=1276)*(i-1276))+((i>1530)*(1530-i))+((i>1786)*(1786-i));
  GreenVal =(i<256)*(1)+(i>255)*(i-255)+(i>510)*(510-i)+(i>1020)*(1020-i)+(i>1274)*(i-1274)+(i>1530)*(i-1531)+(i>1785)*(3571-(2*i));
  BlueVal =(i<764)*(1)+(i>765)*(i-765)+(i>1020)*(1020-i)+(i>1786)*(1786-i);

  if(i>2040){
   i = 1;
  }
  i++;
  delay(Speed);
 } // Fade ENDE
 
    ////////////////
 
  ////////////////
 
  digitalWrite(led, HIGH);       // Status LED EIN   
       delay(50);                // Pause 0,5s
      digitalWrite(led, LOW);    // Status LED AUS
         delay(50);
      digitalWrite(led, HIGH);   // Status LED EIN     
       delay(50);                // Pause 0,5s
      digitalWrite(led, LOW);    // Status LED AUS
         delay(50);
      digitalWrite(led, HIGH);   // Status LED EIN     
       delay(50);                // Pause 0,5s
      digitalWrite(led, LOW);    // Status LED AUS
   
   


void loop() {
if(modus==1){    // Querry pb Modus:1
fade(fadespeed); // Starte Fade
}

if(modus==2){    // Querry pb Modus:2
pcambi();        // pcaMBIwill be used for further project
}

if(modus==3){    // Querry pb Modus:3 in Interrupt gesetzt
//starteServer();
}
   
   
  } // LOOP  Ende
Logged

Pages: [1]   Go Up
Jump to: