I'm making a little program in C++ (i don't really know how to code C++, i use to code scripts with BASH and it's totally different)
that program should have 3 buttons (2-3-4 pins) and 4 leds (5-6-7-8)
8 is not essential...
the program should make leds on 5-6-7 blink randomly and memorize the sequence into an array, and then you got to reproduce it with leds, then it blinks led on 8 pin to signale if right button is pressed, nothing else in the end.
Here is the code:
void setup (){
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
}
void loop ()
{
//First Stage
int cyclenumtoexe = rand()%5+1; //Gets a number Lower than 5 Increased by one (1-5)
int cyclenum = 0;
while (cyclenum<cyclenumtoexe)
{
//get a random number in each sequence... (cyclenumtoexe = sequences)
int ledON = rand()%7+1;
digitalWrite(ledON,HIGH);
delay (250);
digitalWrite(ledON,LOW);
int a_memory[cyclenumtoexe];
int svar1 = 0;
a_memory[svar1] = ledON; //Store Pin Number in array position.
svar1++;
cyclenum++;
}
int svar2 = 0;
char pincheck;
while (svar2<=cyclenumtoexe)
{
pincheck = digitalRead(a_memory[svar2]);
while (pincheck==LOW)
{
delay (25);
}
svar2++;
digitalWrite(8,LOW);
digitalWrite(8,HIGH);
delay (75);
digitalWrite(8,LOW);
delay (75);
digitalWrite(8,HIGH);
delay (75);
digitalWrite(8,LOW);
}
}
but when i try to verify the sketch i got this error:
sketch_jan11a.ino: In function 'void loop()':
sketch_jan11a:76: error: 'a_memory' was not declared in this scope
There were lots of errors but i can't/don't know how to solve this one. Please help me.