Introduction: Setting Up the Circuit
Step 1: Connecting Power and Piezo
Start by wiring up your breadboard with power and ground as in the previous projects.
Wiring up the piezo is simple as well: connect one end of the piezo to ground and the other end to pin 8 on your Arduino.
- Connect the 5V and GND pins on the Arduino to the 5 volt and ground rails on the breadboard.
- Place the piezo buzzer in row E on the breadboard, near the right side. Connect one terminal to the ground rail and the other terminal to digital pin 8.
- Continue to the next step.
- Stuck? HINT: Remember, we are using the tone() function instead of PWM. So, we don't need to use a PWM digital pin with ~ mark for this project!
Step 2: Placing the Buttons
Place your switches on the breadboard as shown in the circuit. This arrangement of resistors and buttons feeding into an analog input is called a resistor ladder. Each of the resistor-button combinations acts as a voltage divider.
- Place 4 buttons on the breadboard, across the center gap. You should leave 1 socket in between each button. After placing each button in the simulator, you can give them labels Button 1 - Button 4 using the drop down menu.
- Connect Button 1 (on the left) directly to the 5V rail through its left terminal.
- Connect the left terminals of the second, third and fourth switches to the 5V rail through resistors. You will use a 220-ohm, 10-kilohm and 1-megohm resistor, in that order.
- Connect all the buttons’ right terminals together with wires.
- Connect the right terminal of any button to analog pin A0. It might be easiest to make this connection from Button 1.
- Finally, connect the right terminal of any button to ground using a 10 k-ohm resistor. It might be easiest to do this with the last button (as shown in the picture)
- Continue to the next step to learn how to write the code for your Keyboard Instrument!
Next Lesson:Writing the Code
We have a be nice policy.
Please be positive and constructive.