Error messages

My group and i have been having problems with our code and we cant figure out how to fix it. Could you help us? Thank you

This is the code

#include <IRremote.h>
#define code1 16712445 //code for forward button
#define code2 16769055 // code received from button LEFT
#define code3 16754775 // code received from button MIDDLE
#define code4 16748655 // code received from button RIGHT

int RECV_PIN = 11; //IR IS PLUGGED INTO PIN 11

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
pinMode(7,OUTPUT); //MAKE PIN 7 AN OUTPUT
pinMode(6,OUTPUT); //MAKE PIN 6 AN OUTPUT
pinMode(5,OUTPUT); //MAKE PIN 5 AN OUTPUT
pinMode(4,OUTPUT); //MAKE PIN 4 AN OUTPUT

}

void loop() {
if (irrecv.decode(&results)) {
unsigned int value = results.value;
switch(value) {
if (== (case code1):

digitalWrite(7,HIGH); //both motors are turned on to push the boat forward
digitalWrite(6,LOW);
digitalWrite(5,HIGH); //ON
digitalWrite(4,LOW);

break;
else if (== (case code2):

digitalWrite(7,HIGH); //only the right motor is turned on to make the boat turn left
digitalWrite(6,LOW);
digitalWrite(5,LOW); //OFF
digitalWrite(4,LOW);

break;
else if (== (case code4):

digitalWrite(7,LOW); //OFF
digitalWrite(6,LOW);
digitalWrite(5,HIGH); //only the left motor is turned on to make the boat turn right
digitalWrite(4,LOW);

break;
else if (== (case code3):

digitalWrite(7,LOW); //all motors are turned off to make the boat stop moving
digitalWrite(6,LOW);
digitalWrite(5,LOW); //OFF
digitalWrite(4,LOW);

}
irrecv.resume(); // Receive the next value

}
}

And here are all the error messages

Arduino: 1.6.8 (Windows 10), Board: “Arduino/Genuino Uno”

C:\Users\Cuirithir\Desktop\full_sketch1\full_sketch1.ino: In function ‘void loop()’:

full_sketch1:38: error: expected primary-expression before ‘==’ token

if (== (case code1):

^

full_sketch1:38: error: expected primary-expression before ‘case’

if (== (case code1):

^

full_sketch1:38: error: expected ‘)’ before ‘case’

full_sketch1:40: error: expected ‘)’ before ‘;’ token

digitalWrite(7,HIGH); //both motors are turned on to push the boat forward

^

full_sketch1:48: error: expected ‘}’ before ‘else’

else if (== (case code2):

^

full_sketch1:48: error: expected ‘}’ before ‘else’

full_sketch1:48: error: expected primary-expression before ‘==’ token

else if (== (case code2):

^

full_sketch1:48: error: expected primary-expression before ‘case’

else if (== (case code2):

^

full_sketch1:48: error: expected ‘)’ before ‘case’

full_sketch1:50: error: expected ‘)’ before ‘;’ token

digitalWrite(7,HIGH); //only the right motor is turned on to make the boat turn left

^

full_sketch1:56: error: break statement not within loop or switch

break;

^

full_sketch1:57: error: ‘else’ without a previous ‘if’

else if (== (case code4):

^

full_sketch1:57: error: expected primary-expression before ‘==’ token

else if (== (case code4):

^

full_sketch1:57: error: expected primary-expression before ‘case’

else if (== (case code4):

^

full_sketch1:57: error: expected ‘)’ before ‘case’

full_sketch1:59: error: expected ‘)’ before ‘;’ token

digitalWrite(7,LOW); //OFF

^

full_sketch1:65: error: break statement not within loop or switch

break;

^

full_sketch1:66: error: ‘else’ without a previous ‘if’

else if (== (case code3):

^

full_sketch1:66: error: expected primary-expression before ‘==’ token

else if (== (case code3):

^

full_sketch1:66: error: expected primary-expression before ‘case’

else if (== (case code3):

^

full_sketch1:66: error: expected ‘)’ before ‘case’

full_sketch1:68: error: expected ‘)’ before ‘;’ token

digitalWrite(7,LOW); //all motors are turned off to make the boat stop moving

^

C:\Users\Cuirithir\Desktop\full_sketch1\full_sketch1.ino: At global scope:

full_sketch1:74: error: ‘irrecv’ does not name a type

irrecv.resume(); // Receive the next value

^

full_sketch1:76: error: expected declaration before ‘}’ token

}

^

exit status 1
expected primary-expression before ‘==’ token

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

  if (== (case code1):

That's not a case - where have you seen that syntax?

Please use code tags when posting code.

switch(value) {
       case code1:
         
            digitalWrite(7,HIGH); //

etc.

When you get the code to compile, and run it, you'll find that the value of code1 etc won't fit in sixteen bits.
Try unsigned long instead.

You can simplify the code a bit by using arrays. See if this makes sense.

#include <IRremote.h>

#define code1  16712445     //code for forward button
#define code2  16769055     // code received from button LEFT
#define code3  16754775     // code received from button MIDDLE
#define code4  16748655     // code received from button RIGHT   

#define ELEMENTS(x)  (sizeof(x) / sizeof(x[0]))

int RECV_PIN = 11; //IR IS PLUGGED INTO PIN 11

int pins[]   = {7, 6, 5, 4};
int states[] = {0, 0, 0, 0};


IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();  // Start the receiver

  for (int i = 0; i < ELEMENTS(pins); i++) {
    pinMode(pins[i], OUTPUT);
  }
}

/*****
 Purpose: to set the pin states

 Paramter list:
  void

 Return value:
  void

 Caution: Assumes pins[] and states[] arrays exist globally
*****/
void WriteData()
{
  for (int i = 0; i < ELEMENTS(pins); i++) {
    digitalWrite(pins[i], states[i]);
  }
}

void loop() {
  if (irrecv.decode(&results)) {
    unsigned int value = results.value;   // I'm assuming value is an int
    switch (value) {
      case 1:
        /*
              digitalWrite(7,HIGH); //both motors are turned on to push the boat forward
              digitalWrite(6,LOW);
              digitalWrite(5,HIGH); //ON
              digitalWrite(4,LOW);

        */
        states[0] = 1;
        states[1] = 0;
        states[2] = 1;
        states[3] = 0;
        WriteData();
        break;

      case 2:

        /*
                    digitalWrite(7,HIGH);  //only the right motor is turned on to make the boat turn left
                    digitalWrite(6,LOW);
                    digitalWrite(5,LOW); //OFF
                    digitalWrite(4,LOW);
        */
        states[0] = 1;
        states[1] = 0;
        states[2] = 0;
        states[3] = 0;
        WriteData();
        break;

      case 3:
        /*
                     digitalWrite(7,LOW); //all motors are turned off to make the boat stop moving
                     digitalWrite(6,LOW);
                     digitalWrite(5,LOW); //OFF
                     digitalWrite(4,LOW);
        */
        states[0] = 0;
        states[1] = 0;
        states[2] = 0;
        states[3] = 0;
        WriteData();
        break;

      case 4:
        /*
                     digitalWrite(7,LOW); //OFF
                     digitalWrite(6,LOW);
                     digitalWrite(5,HIGH); //only the left motor is turned on to make the boat turn right
                     digitalWrite(4,LOW);
        */
        states[0] = 0;
        states[1] = 0;
        states[2] = 1;
        states[3] = 0;
        WriteData();
        break;

      default:
        Serial.print("I shouldn't be here. value = ");
        Serial.println(value);
        break;
    }
    irrecv.resume(); // Receive the next value

  }
}

If it doesn’t make sense, at least it compiles and might serve as a starting point.

EDIT: You could save a few bytes by removing each case call to WriteData() and then call it once before the irrecv.resume() call.

i uploaded the sketch to the arduino but the motors arent responding. Do you know what the problem might be?

Cuirithir:
i uploaded the sketch to the arduino but the motors arent responding. Do you know what the problem might be?

Uploaded what sketch?