Comparing Arrays error please help!

this is supposed to be a simon says game. I've gotten all of the functions so far but now it's time to compare the arrays for the led and the button inputs and this is what I have and I'm now stuck on this error:

3:38: error: expression list treated as compound expression in initializer [-fpermissive]

int ledArray[4];
int buttonArray[4];
int array_cmp(ledArray, buttonArray,4);

void blinkGreen() 
 {digitalWrite(3, HIGH);
  delay(0250);
  digitalWrite(3, LOW);
  delay(0250);
  digitalWrite(3, HIGH);
  delay(0250);
    digitalWrite(3, LOW);}
void blinkRed() 
 {digitalWrite(2, HIGH);
  delay(0250);
  digitalWrite(2, LOW);
  delay(0250);
  digitalWrite(2, HIGH);
  delay(0250);
    digitalWrite(2, LOW);}

const int buttonRed = 7;
const int buttonYellow = 6;
const int buttonGreen = 5;
const int buttonBlue = 8;
const int r = 1; 
const int y = 2;
const int g = 3;
const int b = 4;
int loopCounter = 0;
int count = 0;
int amountOutput=0;
int randLedNumber=random(2,5);
int array_Cmp;

void setup ()
{
 Serial.begin(9600);
 pinMode (2, OUTPUT);
 pinMode (3, OUTPUT);
 pinMode (4, OUTPUT);
 pinMode (5, OUTPUT);
 pinMode (6, INPUT);
 pinMode (7, INPUT);
 pinMode (8, INPUT);
 pinMode (9, INPUT);
}
void loop (){
  loopCounter = 0;
  amountOutput=random(1,5);
  Serial.print(amountOutput);
  do{
  randLedNumber=random(1,6);
  digitalWrite(randLedNumber, HIGH);
  delay(500);
  digitalWrite(randLedNumber, LOW);
  delay(500);
  if (randLedNumber=2)
  {ledArray[loopCounter] == 2;//yellow led connected to relay 2
  loopCounter++;
  delay(1000);}
  else if(randLedNumber=3)
  {ledArray[loopCounter] == 3;//green led connected to relay 3
  loopCounter++;
  delay(1000);}
  else if(randLedNumber=1)
  {ledArray[loopCounter] == 1;//red led connected to relay 1
    loopCounter++;
  delay(1000);}
  else if(randLedNumber=4)
  {ledArray[loopCounter] == 4;//blue led connected to relay 4
  loopCounter++;
  delay(1000);}
}
 while (loopCounter<amountOutput);
  delay(3000);
  loopCounter=0;

 do
 {
   if (digitalRead(8)==LOW)
   {digitalWrite(2, HIGH);
    delay(250);
    digitalWrite(2, LOW);
    buttonArray[loopCounter] == 1; //assigns RED button to array 10
    loopCounter++;
    delay(1000);}
    else if (digitalRead(7)==LOW)
    {digitalWrite(3, HIGH);
     delay(250);
     digitalWrite(3, LOW);
     buttonArray[loopCounter] == 2; //assigns YELLOW button to array 10
    loopCounter++;
    delay(1000);}
    if (digitalRead(6)==LOW)
   {digitalWrite(4, HIGH);
    delay(250);
    digitalWrite(4, LOW);
    buttonArray[loopCounter] == 3; //assigns GREEN button to array 10
    loopCounter++;
    delay(1000);}
   else if (digitalRead(9)==LOW)
   {digitalWrite(5, HIGH);
    delay(250);
    digitalWrite(5, LOW);
    buttonArray[loopCounter] == 4; //assigns BLUE button to array 10
    loopCounter++;
    delay(1000);}
 }
 while (loopCounter<amountOutput);
delay(2000);

}

I get warning but no errors when compiling.

However, you do need to fix this

  if (randLedNumber=2)
  {ledArray[loopCounter] == 2;//yellow led connected to relay 2

unless, of course, you do want to assign the value of 2 to randLedNumber and the second line does nothing with the result of the comparison, which I assume is meant to be an assignment

You have a function prototype like this

int array_cmp(ledArray, buttonArray,4);

but the function is not actually in the program

It is also not a good idea to have a function and variable with very similar names such as array_cmp and array_Cmp. The compiler won't care but you may find it confusing

hi, I fixed it.
As for the comparison, I just need to figure it out. I have no idea what to do and I can't find any examples or anything with the manual?

I want it to light up a random amount of the LEDs in a random sequence and then record it, and then I want it to read the input buttons and record that sequence, and then I want it to compare both sequences but I just can't figure out what to do.

I can't find any examples or anything with the manual?

x = y sets x to the value of y
x == y compares the values of x and y

Any C language book or course will give full details

I tried the simple (==) comparison and got it to compile but now I have other issues:
the ledPrompter meant to show when the game is starting as well as prompt the player when it's time to input doesn't seem to do anything. So I dont even know if it;s doing anything. Also, it doesn't seem to go past round two. I'm sure it's something silly but does anyone see anything I might've missed?
the first While seems like something's wrong. the amountOutput is randomized because I want the amount of LEDs it lights up per round to be random but sometimes it seems to also repeat the same LEDs and then sometimes it also repeats the same exact sequence from the previous time I ran the simulation...The serial monitor is supposed to post each amountOutput and this is what it posted:

251555553333333333000000000003000000000000

int ledArray[5];
int buttonArray[5]; 
boolean result;

void ledPrompter()
{digitalWrite(10, HIGH);
  delay(250);
  digitalWrite(10, LOW);
  delay(250);
  digitalWrite(10, HIGH);
  delay(250);
  digitalWrite(10, LOW);
 delay(250);}
void blinkGreen() 
 {digitalWrite(3, HIGH);
  delay(0250);
  digitalWrite(3, LOW);
  delay(0250);
  digitalWrite(3, HIGH);
  delay(0250);
  digitalWrite(3, LOW);}
void blinkRed() 
 {digitalWrite(2, HIGH);
  delay(0250);
  digitalWrite(2, LOW);
  delay(0250);
  digitalWrite(2, HIGH);
  delay(0250);
    digitalWrite(2, LOW);}
int amountOutput=random(2,8);

const int buttonRed = 7;
const int buttonYellow = 6;
const int buttonGreen = 5;
const int buttonBlue = 8;
const int r = 2; 
const int y = 3;
const int g = 4;
const int b = 5;
const int w = 10;
int loopCounter = 0;
int count = 0;
int randLedNumber=random(2,5);
int array_Cmp;

void setup ()
{
 Serial.begin(9600);
 pinMode (2, OUTPUT);
 pinMode (3, OUTPUT);
 pinMode (4, OUTPUT);
 pinMode (5, OUTPUT);
 pinMode (12, OUTPUT);
 pinMode (6, INPUT);
 pinMode (7, INPUT);
 pinMode (8, INPUT);
 pinMode (9, INPUT);
 
}
void loop (){
  ledPrompter;
  loopCounter = 0;
  amountOutput;
  Serial.print(amountOutput);
  do{
  randLedNumber = random(2,5);
  digitalWrite(randLedNumber, HIGH);
  delay(250);
  digitalWrite(randLedNumber, LOW);
  delay(250);
  if (randLedNumber=2)
  {ledArray[loopCounter] == 2;//yellow led connected to relay 2
  loopCounter++;
  delay(1000);}
  else if(randLedNumber=3)
  {ledArray[loopCounter] == 3;//green led connected to relay 3
  loopCounter++;
  delay(1000);}
  else if(randLedNumber=5)
  {ledArray[loopCounter] == 1;//red led connected to relay 1
    loopCounter++;
  delay(1000);}
  else if(randLedNumber=4)
  {ledArray[loopCounter] == 4;//blue led connected to relay 4
  loopCounter++;
  delay(1000);
  }
  }
  while (loopCounter < amountOutput);
    loopCounter=0;
      ledPrompter;
 do
 {
   if (digitalRead(8)==LOW)
   {digitalWrite(2, HIGH);
    delay(250);
    digitalWrite(2, LOW);
    buttonArray[loopCounter] == 1; //assigns RED button to array 10
    loopCounter++;
    delay(1000);}
    else if (digitalRead(7)==LOW)
    {digitalWrite(3, HIGH);
     delay(250);
     digitalWrite(3, LOW);
     buttonArray[loopCounter] == 2; //assigns YELLOW button to array 10
    loopCounter++;
    delay(1000);}
    if (digitalRead(6)==LOW)
   {digitalWrite(4, HIGH);
    delay(250);
    digitalWrite(4, LOW);
    buttonArray[loopCounter] == 3; //assigns GREEN button to array 10
    loopCounter++;
    delay(1000);}
   else if (digitalRead(9)==LOW)
   {digitalWrite(5, HIGH);
    delay(250);
    digitalWrite(5, LOW);
    buttonArray[loopCounter] == 4; //assigns BLUE button to array 10
    loopCounter++;
    delay(1000);}
 }
 while (loopCounter < amountOutput);
if (buttonArray==ledArray)
{blinkGreen;
 delay(2000);}
  else
  {blinkRed;
   delay(2000);}
  amountOutput=0;
  loopCounter=0;
}

You're not initialising random() so, as the reference for it says, naturally it gives you the same pseudo-random sequence every time. See random() - Arduino Reference

Steve

You've got assignments that should be comparisons, comparisons that should be assignments, and function calls that aren't.

if (randLedNumber=2) // NO!
  {ledArray[loopCounter] == 2;// NO!
  ...
  ...
  else if(randLedNumber=3) // NO
  {ledArray[loopCounter] == 3;// NO!
  ...
  ...
  else if(randLedNumber=5) /// Errr, NO!
  {ledArray[loopCounter] == 1;//Oops, NO!
    
  ...
      ledPrompter;// Oops
 ...
{blinkGreen;// Again, no.

I don't know how your code got so big without testing.

premobowei:
I tried the simple (==) comparison and got it to compile but now I have other issues:
the ledPrompter meant to show when the game is starting as well as prompt the player when it's time to input doesn't seem to do anything. So I dont even know if it;s doing anything. Also, it doesn't seem to go past round two. I'm sure it's something silly but does anyone see anything I might've missed?
the first While seems like something's wrong. the amountOutput is randomized because I want the amount of LEDs it lights up per round to be random but sometimes it seems to also repeat the same LEDs and then sometimes it also repeats the same exact sequence from the previous time I ran the simulation...The serial monitor is supposed to post each amountOutput and this is what it posted:

251555553333333333000000000003000000000000

int ledArray[5];

int buttonArray[5];
boolean result;

void ledPrompter()
{digitalWrite(10, HIGH);
  delay(250);
  digitalWrite(10, LOW);
  delay(250);
  digitalWrite(10, HIGH);
  delay(250);
  digitalWrite(10, LOW);
delay(250);}
void blinkGreen()
{digitalWrite(3, HIGH);
  delay(0250);
  digitalWrite(3, LOW);
  delay(0250);
  digitalWrite(3, HIGH);
  delay(0250);
  digitalWrite(3, LOW);}
void blinkRed()
{digitalWrite(2, HIGH);
  delay(0250);
  digitalWrite(2, LOW);
  delay(0250);
  digitalWrite(2, HIGH);
  delay(0250);
    digitalWrite(2, LOW);}
int amountOutput=random(2,8);

const int buttonRed = 7;
const int buttonYellow = 6;
const int buttonGreen = 5;
const int buttonBlue = 8;
const int r = 2;
const int y = 3;
const int g = 4;
const int b = 5;
const int w = 10;
int loopCounter = 0;
int count = 0;
int randLedNumber=random(2,5);
int array_Cmp;

void setup ()
{
Serial.begin(9600);
pinMode (2, OUTPUT);
pinMode (3, OUTPUT);
pinMode (4, OUTPUT);
pinMode (5, OUTPUT);
pinMode (12, OUTPUT);
pinMode (6, INPUT);
pinMode (7, INPUT);
pinMode (8, INPUT);
pinMode (9, INPUT);

}
void loop (){
  ledPrompter;
  loopCounter = 0;
  amountOutput;
  Serial.print(amountOutput);
  do{
  randLedNumber = random(2,5);
  digitalWrite(randLedNumber, HIGH);
  delay(250);
  digitalWrite(randLedNumber, LOW);
  delay(250);
  if (randLedNumber=2)
  {ledArray[loopCounter] == 2;//yellow led connected to relay 2
  loopCounter++;
  delay(1000);}
  else if(randLedNumber=3)
  {ledArray[loopCounter] == 3;//green led connected to relay 3
  loopCounter++;
  delay(1000);}
  else if(randLedNumber=5)
  {ledArray[loopCounter] == 1;//red led connected to relay 1
    loopCounter++;
  delay(1000);}
  else if(randLedNumber=4)
  {ledArray[loopCounter] == 4;//blue led connected to relay 4
  loopCounter++;
  delay(1000);
  }
  }
  while (loopCounter < amountOutput);
    loopCounter=0;
      ledPrompter;
do
{
  if (digitalRead(8)==LOW)
  {digitalWrite(2, HIGH);
    delay(250);
    digitalWrite(2, LOW);
    buttonArray[loopCounter] == 1; //assigns RED button to array 10
    loopCounter++;
    delay(1000);}
    else if (digitalRead(7)==LOW)
    {digitalWrite(3, HIGH);
    delay(250);
    digitalWrite(3, LOW);
    buttonArray[loopCounter] == 2; //assigns YELLOW button to array 10
    loopCounter++;
    delay(1000);}
    if (digitalRead(6)==LOW)
  {digitalWrite(4, HIGH);
    delay(250);
    digitalWrite(4, LOW);
    buttonArray[loopCounter] == 3; //assigns GREEN button to array 10
    loopCounter++;
    delay(1000);}
  else if (digitalRead(9)==LOW)
  {digitalWrite(5, HIGH);
    delay(250);
    digitalWrite(5, LOW);
    buttonArray[loopCounter] == 4; //assigns BLUE button to array 10
    loopCounter++;
    delay(1000);}
}
while (loopCounter < amountOutput);
if (buttonArray==ledArray)
{blinkGreen;
delay(2000);}
  else
  {blinkRed;
  delay(2000);}
  amountOutput=0;
  loopCounter=0;
}

pls how do I fix this? I tried to put int random on the main and it spammed me with errors

No, you spammed it with errors.
See reply #6

I don't know how I can possibly get you to understand that I'm literally new to this and have no clue what you're talking about. Please help or leave.

Assignment "="
Comparison "=="
Function call "blink();". Not function call "blink;"

Please work through some of the examples on the IDE, or leave.

When you write

I tried to put int random on the main and it spammed me with errors

all I hear is an irritating whining.
That sentence conveys no useful information, because you didn't show the bug-ridden code, or the errors detected.
You are wasting your time and ours by this behaviour.
This isn't about being new to Arduino or C++, it's about knowing how to ask questions that are likely to receive answers.

delay(0250);And when you don't take note of what you have previously been told, it really does seem like you can't be bothered.

premobowei:
I don't know how I can possibly get you to understand that I'm literally new to this and have no clue what you're talking about. Please help or leave.

Did you think of saying in your first post "I'm new to this and this isn't my code it's something I found and I don't really understand any of it"? That would have given us a hint.

By now you should have made at least some changes so post the current version of your program and also any compile errors you are getting. If it compiles then we need details of exactly what works and what doesn't work.

Steve

It is my code up until the part to compare...and the other guy knows I am new cause I've said it in other threads I've made. I don't understand you guys' snarky angry language here. Why is it a war to try to get help?

Why is it a war to get information from you?
I don't understand why you'd rather waste five minutes response time whinging, than posting something that would aid you getting help.

TheMemberFormerlyKnownAsAWOL:
Assignment "="
Comparison "=="
Function call "blink();". Not function call "blink;"

Please work through some of the examples on the IDE, or leave.

When you writeall I hear is an irritating whining.
That sentence conveys no useful information, because you didn't show the bug-ridden code, or the errors detected.
You are wasting your time and ours by this behaviour.
This isn't about being new to Arduino or C++, it's about knowing how to ask questions that are likely to receive answers.

  delay(0250);And when you don't take note of what you have previously been told, it really does seem like you can't be bothered.

every other one is written properly so obviously that was a typo or mistake.

Post your latest entire sketch with the assignments and comparisons fixed and you may get more help.

Have you actually made any changes yet? If so where's the latest code? If not...well what's the point of us even trying!

Steve

premobowei:
every other one is written properly so obviously that was a typo or mistake.

Three typos in blinkRed(), three typos in blinkGreen().

Also, you gave the pins names - why not use them?

There is a library function for comparing arrays (memcmp) - it would save you a lot of time and trouble if you used it, instead of comparing array pointers, which will never be equal.

So I decided to change the format to having it flash one LED and then read for the input that correlates to that LED and decided whether the game continues or ends based on whether or not the right button was pushed. I want to first blink one random light so the amount of light starts with just one (amountOutput no longer randomized); then it'll read for that output and I added amountOutput++ at the end with the while statement so it adds one more to the initial amount with each round but I'm not sure it'll be that easy to get it to work...

int ledArray[5];
int choiceArray[5]; 
boolean result;

bool gameContinue = true;

void ledPrompter()
{digitalWrite(10, HIGH);
  delay(250);
  digitalWrite(10, LOW);
  delay(250);
  digitalWrite(10, HIGH);
  delay(250);
  digitalWrite(10, LOW);
 delay(500);}
void blinkGreen() 
 {digitalWrite(3, HIGH);
  delay(0250);
  digitalWrite(3, LOW);
  delay(0250);
  digitalWrite(3, HIGH);
  delay(0250);
  digitalWrite(3, LOW);}
void blinkRed() 
 {digitalWrite(2, HIGH);
  delay(0250);
  digitalWrite(2, LOW);
  delay(0250);
  digitalWrite(2, HIGH);
  delay(0250);
    digitalWrite(2, LOW);}
int amountOutput=1;

const int buttonRed = 7;
const int buttonYellow = 6;
const int buttonGreen = 5;
const int buttonBlue = 8;
const int r = 2; 
const int y = 3;
const int g = 4;
const int b = 5;
const int w = 10;
int loopCounter = 0;
int count = 0;
int randLedNumber=random(2,5);
int array_Cmp;

void setup ()
{  void ledPrompter ();
 Serial.begin(9600);
 pinMode (2, OUTPUT);
 pinMode (3, OUTPUT);
 pinMode (4, OUTPUT);
 pinMode (5, OUTPUT);
 pinMode (12, OUTPUT);
 pinMode (6, INPUT);
 pinMode (7, INPUT);
 pinMode (8, INPUT);
 pinMode (9, INPUT);
 
}
void loop (){
  //ledPrompter();
  delay(2000);
  loopCounter = 0;
  amountOutput=1;
  Serial.print(amountOutput);
  do{
  randLedNumber = random(2,5);
  digitalWrite(randLedNumber, HIGH);
  delay(250);
  digitalWrite(randLedNumber, LOW);
  delay(250);
  if (randLedNumber=2)
  {choiceArray[loopCounter] == 2;//yellow led connected to relay 2
  loopCounter++;
  delay(1000);}
  else if(randLedNumber=3)
  {choiceArray[loopCounter] == 3;//green led connected to relay 3
  loopCounter++;
  delay(1000);}
  else if(randLedNumber=5)
  {choiceArray[loopCounter] == 1;//red led connected to relay 1
    loopCounter++;
  delay(1000);}
  else if(randLedNumber=4)
  {choiceArray[loopCounter] == 4;//blue led connected to relay 4
  loopCounter++;
  delay(1000);
  }
  }
  while (loopCounter < amountOutput);
    loopCounter=0;
     void ledPrompter();
 do
 {
   //r=2,y=3,g=4,b=5
   if (choiceArray[loopCounter] == 2)
   {digitalRead(6);
    if (digitalRead(6)==LOW)
    {loopCounter++
      gameContinue==true;
    }
     else if (digitalRead(7,8,9)==LOW)
     {gameContinue==false}
     //blinkRed(2);
     delay(3000);
    //ledPrompter(1);}
   if (choiceArray[loopCounter] == 3)
   {digitalRead(7);
    if (digitalRead(7)==LOW)
    {gameContinue==true;
    loopCounter++}
     else if (digitalRead(6,8,9)==LOW)
     {gameContinue==false}
     //blinkRed(2);
     delay(3000);
    //ledPrompter(1);}
   if (choiceArray[loopCounter] == 4)
   {digitalRead(8);
    if (digitalRead(8)==LOW)
    {gameContinue==true;
    loopCounter++}
     else if (digitalRead(6,7,9)==LOW)
     {gameContinue==false}
     //blinkRed(2);
     delay(3000);
    //ledPrompter(1);}
    if (choiceArray[loopCounter] == 5)
   {digitalRead(9);
    if (digitalRead(9)==LOW)
    {gameContinue==true;
    loopCounter++}
     else if (digitalRead(6,7,8)==LOW)
     {gameContinue==false}
     //blinkRed(2);
     delay(3000);
    //ledPrompter(1);}
   
 }
 while (gameContinue==true) and loopCounter==amountOutput;
 amountOutput++;
 delay(2000);
}

THESE ARE MY ERROR MESSAGES

In function 'void loop()':
103:32: error: too many arguments to function 'int digitalRead(uint8_t)'
1:0:
127:5: note: declared here

104:26: error: expected ';' before '}' token
112:32: error: too many arguments to function 'int digitalRead(uint8_t)'
1:0:
127:5: note: declared here

113:26: error: expected ';' before '}' token
121:32: error: too many arguments to function 'int digitalRead(uint8_t)'
1:0:
127:5: note: declared here

122:26: error: expected ';' before '}' token
130:32: error: too many arguments to function 'int digitalRead(uint8_t)'
1:0:
127:5: note: declared here

131:26: error: expected ';' before '}' token
140:1: error: expected '}' at end of input
140:1: error: expected '}' at end of input
140:1: error: expected '}' at end of input
140:1: error: expected 'while' at end of input
140:1: error: expected '(' at end of input
140:1: error: expected primary-expression at end of input
140:1: error: expected ')' at end of input
140:1: error: expected ';' at end of input
140:1: error: expected '}' at end of input

if (randLedNumber=2)
  {choiceArray[loopCounter] == 2;/

"=" is an assignment - it is rarely appropriate* in an "if"
"==" is a comparison - it is rarely appropriate* OUTSIDE of an "if".

delay(0250);

This is getting tedious.

if (digitalRead(7, 8, 9) == LOW)

The IDE has many worked examples using digitalRead.
Not one has a digitalRead in it that looks remotely like this.

  //r=2,y=3,g=4,b=5

Your code already has variables with these names, SO WHY NOT USE THEM?

void setup ()
{ void ledPrompter ();

Strange place for a function prototype, but also a strange place for a call to a function that uses pins that haven't been initialised yet.

*At your level of experience.