PLEASE HELP FIX THIS CODE!

I don't know what I did wrong and don't know what to do. can someone help me

compile errors are:

sketch_nov27a, cpp: in function 'void loop()':
sketch_nov27a, cpp:117:7: error: expected ';' before '}' token

#include <IRremote.h>

int IR_Recv = 3; //IR Receiver Pin 3
int g_ledPin = 5; //green LED pin 5
int y_ledPin = 6; //yellow LED pin 6
int r_ledPin = 9; //red LED pin 9
int b_ledPin = 10; //blue LED pin 10
int ledPins[] = {5, 6, 9, 10}; //array with all the LED's pins
int ledStates[] ={0, 0, 0, 0}; //this means the LED's states at first is 0 = LOW
int i=0; //LED index for the arrays

IRrecv irrecv(IR_Recv);
decode_results results;

//variables to make the LED blink when selected
int ledState = LOW; // ledState to turn the LED on or off
long previousMillis = 0; // stores last time LED was updated
long interval = 1000; // interval at which to blink (milliseconds)

void setup(){
Serial.begin(9600); //starts serial communication
irrecv.enableIRIn(); // Starts the receiver
pinMode(g_ledPin, OUTPUT); // sets the digital pin as output
pinMode(y_ledPin, OUTPUT); // sets the digital pin as output
pinMode(r_ledPin, OUTPUT); // sets the digital pin as output
pinMode(b_ledPin, OUTPUT); // sets the digital pin as output
}

void loop(){
//decodes the infrared input
if (irrecv.decode(&results)){
long int decCode = results.value;
Serial.println(decCode);
//switch case to use the selected remote control button
switch (results.value){
case 57936: //when you press the Forward button
//this if/else statement makes sure that LED is ON or OFF before move to the next LED
if(ledStates*==0)*
_ digitalWrite(ledPins*, LOW);_
_
else*_
_ digitalWrite(ledPins*, HIGH);
Serial.println("Next LED");
//makes sure that when we reach the last LED it goes to the first LED again*
* if(i>=3)
i=-1;
i+=1;
break;*_

* case 57928: //when you press the Reverse button*
* //this if/else statement makes sure that LED is ON or OFF before move to the previous LED*
_ if(ledStates*==0)
digitalWrite(ledPins, LOW);
else*

digitalWrite(ledPins*, HIGH);
Serial.println("Previous LED");
//makes sure that when we reach the first LED it goes to the last LED*

* if(i<=0)
i=4;
i-=1;
break;*_

* case 57932: //when you press the Mute button*
_ if(ledStates*==0){ //if the LED is off, It will turn on*
* Serial.println("Turns ON the LED Selected");
digitalWrite(ledPins, HIGH); //sets the LED on*

ledStates*=1; //updates the LED state*
* }
else{
Serial.println("Turns OFF the LED Selected"); //else: the LED is on, It will turn off*

digitalWrite(ledPins*, LOW); //sets the LED off*
ledStates*=0; //updates the LED state*
* }
break;*_

* case 57920: //when you press the Power button*
* Serial.println("Turns OFF all the LED's");*
* digitalWrite(g_ledPin, LOW); // sets the green LED off*
* ledStates[0] =0; // updates the LED state*
* digitalWrite(y_ledPin, LOW); // sets the yellow LED off*
* ledStates[1] =0; // updates the LED state*
* digitalWrite(r_ledPin, LOW); // sets the red LED off*
* ledStates[2] =0; // updates the LED state*
* digitalWrite(b_ledPin, LOW); // sets the blue LED off*
* ledStates[3] =0; // updates the LED state*
* break;*

* default:*
* Serial.println("Waiting");*
* }*
* irrecv.resume(); // Receives the next value from the button you press*
* }*
* //this if statment makes the LED blink if it's selected and off*
_ if(ledStates*==0){
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED*

* previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else*

* ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPins, ledState)
}
}
}*_

If you put every { on a new line, where it belongs, and used Tools + Auto Format to keep your code properly indented, the missing } would be obvious.

If you use IDE 1.6.6 it displays and highlights the error line for you.

would I need a ; after else

No, but perhaps you need one after this:-

digitalWrite(ledPins, ledState)

Also:

You really should have read the How to use this forum - please read post at the top of the index page and How to use this forum before posting.

ie Your code and any error messages should always be placed between code tags. Posting it inline as you have done makes it much harder to read or copy and paste for diagnosis.

It's still not too late to edit your post and do this. You'll make potential helpers much happier. :slight_smile:

      else
        ledState = LOW;
      // set the LED with the ledState of the variable:
      digitalWrite(ledPins, ledState) <<<< need ; right here as Delta_G indicated
      }
    }
  }

You should use { } after the if's and else's to show what code belongs with the sections. Be much easier to follow what you're doing.

CrossRoads:

      else

ledState = LOW;
     // set the LED with the ledState of the variable:
     digitalWrite(ledPins, ledState) <<<< need ; right here as Delta_G indicated
     }
   }
 }



You should use { } after the if's and else's to show what code belongs with the sections. Be much easier to follow what you're doing.

I don't. (When only one line follows the 'if' or 'else', of course.) But I do always use a 4-character indent rather than 2. And I'm used to it, so to me, my code is easily readable.
I like to keep brackets to a minimum where possible, because then more code fits on the screen. (Horses for courses, I think. :slight_smile: )