For this piece of code, you combine 4 inputs and 2 outputs. Each input will affect both outputs- each button press creates a tone and turns on a light. You’re adding together many simple parts to create a more complex and interesting project!
Read the Code Walkthrough Text (click to open)
New Concept: Code Combinations
Combining past projects of your own, or using other people's code with your own new ideas, is very common and a great way to speed up your projects and get help from others. Learning to combine code correctly is a skill in itself.
You need to think carefully about how the new commands may interact with existing code. For example, say you want to combine a program that flashes a light for a second with a program that beeps a speaker on and off once a second. If you copy every single line from one program to another, you'll end up with two delays in your program- not what you intended.
When you want to combine two pieces of code, especially when there is complicated syntax, try to break down the code into smaller chunks in your mind, recognizing what each line is meant to do by itself.