# Lesson goal: Sound a buzzer if a math problem is answered wrong

Previous: LEDs for math test | Home | Next: Read a voltage

In the last lesson, you used LEDs to tell a person if a math problem answer was right or wrong. In this lesson, let's turn on a loud buzzer to go "buzz-buzz-buzz" if they answer a math problem wrong. This should make people study their math!

# Now you try. Go for it! Build us a wrong-answer buzzer!

Program
This code will not run! Following the logic, figure how how to compare sum (which holds the correct answer), and ans, which is the answer the person typed. The body of the if statement should be executed if the wrong answer was given, so the for-loop can buzz the buzzer 3 times. You'll have to fix the digitalwrite statements too, to "flash" the buzzer, much like you flashed the LED in this lesson. Good luck!

Electronics
Here is what your Arduino assembly should look like for this lesson. There is a bit of complication here, because the Arudino can't power a buzzer directly, hence the need for the 9V battery and the transistor.

In this circuit, pin 13 of the Arduino is connected to the base of a 3904 transistor. When pin 13 is brought to HIGH, the transistor will turn on, allowing current to flow from the red lead on the 9V battery, into the buzzer, out of the buzzer, into the collector of the transistor, then out of the emitter of the transistor, and back to the black lead of the battery--all making the buzzer turn-on. To turn it off again, pin 13 of the Arduino should be brought LOW again. So in this example, the transistor behaves like an Arduino-controlled switch.

Dismiss.
Show a friend, family member, or teacher what you've done!