int myInts[5];
int I=0;
int A=0;
int B=0;
int C=0;
int led1=1;
int led2=2;
int led3=3;
int led4=4;
void setup() {
// put your setup code here, to run once:
pinMode(11, OUTPUT);
pinMode(8, OUTPUT);
pinMode(3, OUTPUT);
pinMode(9, OUTPUT);
pinMode(13, OUTPUT);
pinMode(6, OUTPUT);
pinMode(12, OUTPUT);
pinMode(2, OUTPUT);
pinMode(7, OUTPUT);
initarray();
}
void loop() {
// put your main code here, to run repeatedly:
if (buttonPressed(11) == HIGH){
ledOn(8);
myInts[I] = led1;
I++;
}
if (buttonPressed(9) == HIGH){
ledOn(13);
myInts[I] = led2;
I++;
}
if (buttonPressed(6) == HIGH){
ledOn(12);
myInts[I] = led3;
I++;
}
if (buttonPressed(7) == HIGH){
ledOn(2);
myInts[I] = led4;
I++;
}
if (digitalRead(3) == HIGH){
if (myInts[A] == led1){
digitalWrite(8, LOW);
A++;
delay(500);
}
if (myInts[A] == led2){
digitalWrite(13, LOW);
A++;
delay(500);
}
if (myInts[A] == led3){
digitalWrite(12, LOW);
A++;
delay(500);
}
if (myInts[A] == led4){
digitalWrite(2, LOW);
A++;
delay(500);
}
}
}
void buttonPressed(int pinNumber){
digitalRead(pinNumber);
}
void ledOn(int pinNumber){
digitalWrite(pinNumber, HIGH);
}
void ledOff(int pinNumber){
digitalWrite(pinNumber, LOW);
}
void initarray(){
for (int i=0; i<=4; i++){
myInts[i]=-1;
}
}
I am given the error "Error compiling for board Arduino/Genuino Uno" and am not sure where the error is as it doesn't give me any highlighted lines. I am using an arduino uno. I am trying to build a game where you can turn on 4 lights in any order and they will then turn off in that same order using an array.
It gave you more than that. Exit status 1 means that there was an error. But if you scroll up above that you will find the actual error message along with the line number.
BTW: your buttonPressed function is useless. You have it read the button and throw away the result and return void. Did you want that to return the value from the digitalRead? If so then the function needs an appropriate return type and a return statement. It can't return void if you want some data back from it.
Your error is "error: invalid operands of types 'void' and 'int' to binary 'operator=='"
You can't compare an integer to the result of a function that returns 'void'.
In file included from sketch/sketch_dec06a.ino.cpp:1:0:
/Users/john/Documents/Arduino/sketch_dec06a/sketch_dec06a.ino: In function 'void loop()':
/Applications/Arduino 1.8.7.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:40:14: error: invalid operands of types 'void' and 'int' to binary 'operator=='
#define HIGH 0x1
^
/Users/john/Documents/Arduino/sketch_dec06a/sketch_dec06a.ino:27:28: note: in expansion of macro 'HIGH'
if (buttonPressed(11) == HIGH){
^
/Applications/Arduino 1.8.7.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:40:14: error: invalid operands of types 'void' and 'int' to binary 'operator=='
#define HIGH 0x1
^
/Users/john/Documents/Arduino/sketch_dec06a/sketch_dec06a.ino:32:27: note: in expansion of macro 'HIGH'
if (buttonPressed(9) == HIGH){
^
/Applications/Arduino 1.8.7.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:40:14: error: invalid operands of types 'void' and 'int' to binary 'operator=='
#define HIGH 0x1
^
/Users/john/Documents/Arduino/sketch_dec06a/sketch_dec06a.ino:37:27: note: in expansion of macro 'HIGH'
if (buttonPressed(6) == HIGH){
^
/Applications/Arduino 1.8.7.app/Contents/Java/hardware/arduino/avr/cores/arduino/Arduino.h:40:14: error: invalid operands of types 'void' and 'int' to binary 'operator=='
#define HIGH 0x1
^
/Users/john/Documents/Arduino/sketch_dec06a/sketch_dec06a.ino:42:27: note: in expansion of macro 'HIGH'
if (buttonPressed(7) == HIGH){
^
exit status 1
Error compiling for board Arduino/Genuino Uno.
the issue is solved now thank you