Question: #3 Program is for an Arduino board Debounce. Using the circuit from #2 above. Write a new program that counts up the number of times

#3 Program is for an Arduino board

Debounce. Using the circuit from #2 above. Write a new program that counts up the number of times you press the pushbutton. It should only count and print on the screen once per press on the pushbutton like this:

0

1

2

THIS IS Circuit #2

(

int LED = 13; int BUTTON = 7; void setup() { // set the baud rate for Serial monitor Serial.begin(9600); // set the pin modes pinMode(LED, OUTPUT); pinMode(BUTTON, INPUT); digitalWrite(LED, HIGH); // turn on the LED delay(1000 * random(3, 5)); // sleep a random number of seconds between 3-5 unsigned long startTime = millis(); // start timing while (digitalRead(BUTTON) == HIGH); // the button is in HIGH state when not pressed unsigned long endTime = millis(); // stop timing Serial.print("Your reaction time is: "); Serial.println(endTime - startTime);

if (endTime - startTime <= 150)

Serial.println("You cheated!"); }

void loop() {

}

)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!