Lesson four of my Spring 2021 Intro to Electronics for Kids class! This lesson we will hook up a buzzer and make some noise!
Here’s a printable PDF of this lesson so you can follow along without having to have this page up on a screen.
Mode Selector Button
In the first three lessons, the microcontroller stayed in its default configuration. However there are 4 modes programmed into the microcontroller by my code. To switch between modes, we need to send a signal to the microcontroller in the right way.
Last lesson we saw that it is possible to hook up a button to the microcontroller, so that when the button is pressed the microcontroller can receive a signal. This week we will connect two buttons. One will tell the microcontroller to switch modes, and the other button will be the ‘action’ button.
We’re going to start with most of the wires removed from the last project. So carefully remove your LED and Resistor if they are still on your board. Also remove any jumper wires from the board. Go ahead and leave in the button if it’s there, since those are a bit hard to place and remove. If you’ve already removed it, that’s fine too.
Add the new button across the middle gap like we’ve done before. Place the button pins in rows 10 and 12.
Then add the wire from the microcontroller to the button: (4, h) to (10, h).
Finally add the wire from the button to ground: (12, j) to blue ground rail.
If you have everything connected correctly, when you press the button the LED should light up and stay on once you let go. Pressing and releasing the button again will turn the LED off.
What happens if you swap the two wires connected to the button?
Note that Tinkercad does not support the Adafruit QT-Py microcontroller. So I had to write slightly different code that would work with an Arduino UNO instead. The functionality is mostly the same, but the wiring is fairly different, as the UNO is not as fancy as the QT-Py, and requires some extra wiring and resistors.