First of all, I consider myself new to the Arduino environment, therefore I may oversee some basic things.
So, I got a function in which a random number is generated. Every time I press (a) button (1) the function is called and thereby a new number is generated. But when another button (3) is pressed, I would like to receive the last number generated in that first function to get it compared with the input which is set by pressing button 2. What's is the easiest way of doing this?
void BINARY() //which is called by button 1
{
int random_number = random(0, 16);
for (int i = 0; i < 4; i++)
{
if (bitRead(random_number, i) == 1)
{
digitalWrite(ledPin[i], LOW);
}
else
{
digitalWrite(ledPin[i], HIGH);
}
}
}
void GUESSING_THE_NUMBER() //which is called by button 2
{
//Here goes the code to set your guess
}
void COMPARE() //which is called by button 3
{
//I would like to compare input with the last random number generated
}