SunFounder 3in1 Kit
(continued from previous page)
Serial.print(currentTime - timer);
Serial.println(" ms");
} else if (flag == 1) {
Serial.println("Wrong Click!");
}
flag = -1;
}
This is the function that will be triggered when button 1 is pressed. When button 1 is pressed, if the
flag is 0 at this time, the response time will be printed, otherwise the press error will be prompted.
4. About pressed2() function
void pressed2() {
if (flag == -1) {
return;
}
if (flag == 1) {
int currentTime =millis();
Serial.print("Correct! You reaction time is : ");
Serial.print(currentTime - timer);
Serial.println(" ms");
} else if (flag == 0) {
Serial.println("Wrong Click!");
}
flag = -1;
}
This is the function that will be triggered when button 2 is pressed. When button 2 is pressed, if the
flag is 1 at this time, the response time will be printed, otherwise the press error will be prompted.
4.6.6 6.6 Guess Number
Guessing Numbers is a fun party game where you and your friends take turns inputting a number (0~99). The range
will be smaller with the inputting of the number till a player answers the riddle correctly. Then the player is defeated
and punished. For example, if the lucky number is 51 which the players cannot see, and the player 1 inputs 50, the
prompt of number range changes to 50~99; if the player 2 inputs 70, the range of number can be 50~70; if the player 3
inputs 51, he or she is the unlucky one. Here, we use IR Remote Controller to input numbers and use LCD to output
outcomes.
Required Components
In this project, we need the following components.
It’s definitely convenient to buy a whole kit, here’s the link:
Name ITEMS IN THIS KIT LINK
3 in 1 Starter Kit 380+
You can also buy them separately from the links below.
214 Chapter 4. Basic Projects