EasyManua.ls Logo

SunFounder 3in1 Kit - Page 214

Default Icon
351 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder 3in1 Kit
2. Check if it’s time to beep
The code calculates the difference between the current time and the previous beep time, and if the
difference is greater than or equal to the interval time, it triggers the buzzer and updates the previous
beep time.
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= intervals) {
Serial.println("Beeping!");
beep();
previousMillis = currentMillis;
}
3. Update LCD display
The code clears the LCD display and then displays “Dis:” and the current distance in centimeters on
the first line.
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Dis: ");
lcd.print(distance);
lcd.print(" cm");
delay(100);
4.6.5 6.5 Reaction Game
Our body has many reaction times, such as audio RT, visual RT, touch RT, etc.
Reaction times have many effects on our daily life, for example, slower than normal reaction times when driving can
lead to serious consequences.
In this project, we use 3 buttons and 2 LEDs to measure our visual reaction time.
The serial monitor of the Arduino displays the message “waiting. . . After pressing the Ready button, one of the two
LEDs must light up randomly after a random time interval. It is important that the testee pushes the corresponding
button as soon as possible. The Arduino records the time difference between when the LED lights up and when the
person presses the corresponding button, and prints the measured response time on the Arduino serial monitor.
Required Components
In this project, we need the following components.
Its 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.
210 Chapter 4. Basic Projects

Related product manuals