Help - error: expected primary-expression before '>' token

Hello everybody,

I am doing this project where I do a remake of the popular game Simon with an Arduino Uno and I would need a bit of help.

Here is the game presentation for those of you who are not familiar with it: Simon (game) - Wikipedia

So in the project the buttons are replaced with a distance ultrasound sensors and the different colors are defined by different height levels (green:0-15cm; red 15-30cm; yellow 30-45cm and blue 45-60cm).

I have posted here the first part of the code, where a sequence of 4 colors is recorded. 'e=0,1,2,3' is the variable that counts how many colors have been saved. 'p=1,2,3,4' is the variable for the different height levels. The variables v1, v2, v3, v4 are the height recorded that are going to be compared to the second player's sequence v5, v6, v7, v8 but I haven't done that part yet as I don't know if the first part is correct.

So when I check the code this is what I get: error: expected primary-expression before '>' token on line 55, so my question is why is that?

As this is my actual first Arduino project, I have quite limited knowledge and I am not even sure that the code is even working so I would greatly apreciate your help!

Thanks in advance!

ps: I am also sorry that some of the comments are in french

essai1.ino (6.44 KB)

#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin

/*  Blue – 415 Hz – G#4 (true pitch 415.305 Hz)
 Yellow – 310 Hz – D#4 (true pitch 311.127 Hz)
 Red – 252 Hz ? B3 (true pitch 247.942 Hz)
 Green – 209 Hz – G#3 (true pitch 207.652 Hz)
 */

int maximumRange = 200;   // Maximum range needed
int minimumRange = 0;     // Minimum range needed
long duration, distance;
int temps = 1000;
int v1=0;
int v2=0;
int v3=0;
int v4=0;
int v5=0;
int v6=0;
int v7=0;
int v8=0;
int e=0;                   //N° Enregistrement
int p=0;                   //Palier

void setup() 

{

  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(9, OUTPUT);          //Neon bleu
  pinMode(10, OUTPUT);         //Neon vert
  pinMode(11, OUTPUT);         //Neon rouge
  pinMode(12, OUTPUT);         //Neon jaune
  pinMode(13, OUTPUT);

}

void loop() 

{

  digitalWrite(trigPin, LOW); 
  delayMicroseconds(2); 

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); 

  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration/58.2;


  while(e=>0 && e<=3)                               //Définit le palier

  { 

    if(distance<0 && distance>60)
    {
      p=0;
      break;
    }

    if(distance>0 && distance<=15)
    {
      p=1;
      break;
    }

    if(distance>15 && distance<=30)
    {
      p=2;
      break;
    }

    if(distance>30 && distance<=45)
    {
      p=3;
      break;
    }

    if(distance>45 && distance<=60)
    {
      p=4;
      break;
    }

    break;
  }


  if (e=0)                                      //Enregistrment 1
  {
    switch (p)

    {
    case 1 :

      digitalWrite(9, HIGH);
      tone (13, 415);
      Serial.println("bleu");
      delay(temps);
      noTone(13);
      digitalWrite(9, LOW);
      e=e+1;
      v1=v1+1;

    case 2 :

      digitalWrite(10, HIGH);
      Serial.println("vert");
      tone (13, 209);
      delay(temps);
      noTone(13);
      digitalWrite(10, LOW);
      e=e+1;
      v1=v1+2;

    case 3 :

      digitalWrite(11, HIGH);
      Serial.println("rouge");
      tone (13, 252);
      delay(temps);
      noTone(13);
      digitalWrite(11, LOW);
      e=e+1;
      v1=v1+3;

    case 4 :

      digitalWrite(12, HIGH);
      Serial.println("jaune");
      tone (13, 310);
      delay(temps);
      noTone(13);
      digitalWrite(12, LOW);
      e=e+1;
      v1=v1+4;


    case 0 :

      Serial.println("out of range");
      noTone(13);

      break;
      Serial.print(v1) ;
    }
  }        

  if (e=1)                                        //Enregistrement 2
  {
    switch (p)

    {
    case 1 :

      digitalWrite(9, HIGH);
      tone (13, 415);
      Serial.println("bleu");
      delay(temps);
      noTone(13);
      digitalWrite(9, LOW);
      e=e+1;
      v2=v2+1;

    case 2 :

      digitalWrite(10, HIGH);
      Serial.println("vert");
      tone (13, 209);
      delay(temps);
      noTone(13);
      digitalWrite(10, LOW);
      e=e+1;
      v2=v2+2;

    case 3 :

      digitalWrite(11, HIGH);
      Serial.println("rouge");
      tone (13, 252);
      delay(temps);
      noTone(13);
      digitalWrite(11, LOW);
      e=e+1;
      v2=v2+3;

    case 4 :


      digitalWrite(12, HIGH);
      Serial.println("jaune");
      tone (13, 310);
      delay(temps);
      noTone(13);
      digitalWrite(12, LOW);
      e=e+1;
      v2=v2+4;

    case 0 :

      Serial.println("out of range");
      noTone(13);

      break;
      Serial.print(v2);
    }
  }           

  if(e=2)                                         //Enregistrement 3
  {
    switch (p)

    {
    case 1 :

      digitalWrite(9, HIGH);
      tone (13, 415);
      Serial.println("bleu");
      delay(temps);
      noTone(13);
      digitalWrite(9, LOW);
      e=e+1;
      v3=v3+1;

    case 2 :

      digitalWrite(10, HIGH);
      Serial.println("vert");
      tone (13, 209);
      delay(temps);
      noTone(13);
      digitalWrite(10, LOW);
      e=e+1;
      v3=v3+1;

    case 3 :

      digitalWrite(11, HIGH);
      Serial.println("rouge");
      tone (13, 252);
      delay(temps);
      noTone(13);
      digitalWrite(11, LOW);
      e=e+1;
      v3=v3+1;

    case 4 :

      digitalWrite(12, HIGH);
      Serial.println("jaune");
      tone (13, 310);
      delay(temps);
      noTone(13);
      digitalWrite(12, LOW);
      e=e+1;
      v3=v3+1;


    case 0 :

      Serial.println("out of range");
      noTone(13);

      break;
      Serial.print(v3);
    }
  }         


  if(e=3)

    switch (p)

    {
    case 1 :

      digitalWrite(9, HIGH);
      tone (13, 415);
      Serial.println("bleu");
      delay(temps);
      noTone(13);
      digitalWrite(9, LOW);
      e=e+1;
      v4=v4+1;

    case 2 :

      digitalWrite(10, HIGH);
      Serial.println("vert");
      tone (13, 209);
      delay(temps);
      noTone(13);
      digitalWrite(10, LOW);
      e=e+1;
      v4=v4+2;

    case 3 :

      digitalWrite(11, HIGH);
      Serial.println("rouge");
      tone (13, 252);
      delay(temps);
      noTone(13);
      digitalWrite(11, LOW);
      e=e+1;
      v4=v4+3;

    case 4 :


      digitalWrite(12, HIGH);
      Serial.println("jaune");
      tone (13, 310);
      delay(temps);
      noTone(13);
      digitalWrite(12, LOW);
      e=e+1;
      v4=v4+4;

    case 0 :

      Serial.println("out of range");
      noTone(13);

      break;
      Serial.print(v4);

    }

}

Look, I just posted your code.
Why didn't you do that?

if(distance<0 && distance>60)

Like that's going to happen.

Missing a ; or a ) or a } somewhere.
Use CTRL-T to autoformat your code, should help you find it.

Also look for things like this:

if (e=0)

this needs == for a comparison.
1 = is an assignment.

AWOL:

if(distance<0 && distance>60)

Like that's going to happen.

Yes sorry the and '&&' should be an or '||'

Ignore it.
Concentrate on the if (e= x)

CrossRoads:
Missing a ; or a ) or a } somewhere.
Use CTRL-T to autoformat your code, should help you find it.

Also look for things like this:

if (e=0)

this needs == for a comparison.
1 = is an assignment.

Thak you very much! It is working now, or at least it is correctly written :slight_smile:

It was a syntax mistake :slight_smile:

AWOL:
Ignore it.
Concentrate on the if (e= x)

 if (e==x)

?

Yes