This code combines 4 button inputs to vary the output of a speaker. Each input is assigned a different output tone using if-else if statements. Once each button is set up to receive input and the speaker is set as an OUTPUT, the loop checks the status of each button until it finds one that is pulled LOW by a press. Then, it runs the code of that statement.
Read the Code Walkthrough Text (click to open)
New Concept: Multiple Inputs
You can think about the components you're using in a program as building blocks. They have different abilities, but you can combine them with code to create something unique.
Using multiple inputs of the same type, like four buttons, is simple as long as you keep track of each component. All of the same functions, like digitalRead() or digitalWrite() will work with multiple components in the same program.