๐ ๏ธ Section project: the music box
Section 4: Sound and movementLesson 4.4 ยท โฑ 12 min
๐ฏ Project goal
When you press the button, the LED lights up and the buzzer plays a tune of 3 notes or more. When you let go, everything goes quiet.
- Plan on paper: what happens when pressed? And what happens when released?
- Use if โฆ else inside loop.
- In the if part: turn on the LED and play the notes.
- In the else part: turn off the LED and silence the buzzer.
๐ Another example: a light with every note
When pressed: the LED lights with every note and goes off between them.


โ๏ธ Practise
Build the music box.
โ๏ธ Practise here in the lessonโ Close the labor open the lab in a new page โ
๐ฏ Challenge yourself
Easy
When pressed: the LED lights up and plays 3 notes.
๐ Show the solution๐ Hide the solution


Result: light and a tune.
Medium
Not pressed: the LED blinks slowly, waiting. Pressed: it plays.
๐ Show the solution๐ Hide the solution


Result: it waits, then plays.
Hard
A long music box: 5 notes, and the LED blinks with every note.
๐ Show the solution๐ Hide the solution


Result: a tune and a blinking light.

