Error in Code can you help me?

Hi this code isn´t my code but it didn´t working can you help me pls?

[Sure, I’ll add some code tags for you. Please use the </> button in the future.]

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

int RECV_PIN = 2;  // IR-Receiver PIN
int led = 13;       // Satus-LED PIN
int modus;          // Modus for Interrupt-Querry
int ledr = 9;       // RGB LED red PIN
int ledg = 10;       // RGB LED green PIN                      
int ledb = 11;       // 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

but it didn´t work

Are you sure you've told us everything?

You seem to have forgotten the tags - here's a spare pair you can have [code][/code]

So what does it do? And what do you expect it to do?

And please use code tags when posting code. Use AWOL's spare pair pkease :slight_smile:

You can NOT use delay() in an interrupt service routine.

It should control a RGB LED with a IR-Receiver

And . .?

Why do you have statements between "} // Fade ENDE" and the beginning of loop() ??

The only Thing That doesn't Work is the debug command

BearGear:
The only Thing That doesn't Work is the debug command

If it works then do you need the debug command :slight_smile:

That's odd, because that's the first occurrence of "debug" on this page.