ุงู†ุชู‚ู„ ู„ู„ู…ุญุชูˆู‰
Robo EgyptRobo Egypt
โ˜ฐ Course contents
Robo Maker: home
0. Lab tour1
1. The start: the Arduino6
2. Wiring and the traffic light4
3. Inputs: the button4
4. Sound and movement5
5. Sensors and numbers5
6. Distance, the screen and colours5
7. Motors and the car4
8. The project: the city's smart gate3
9. From blocks to C++ code5
10. Sensors and screens in code5
11. Smart systems5
12. Bluetooth: control from the phone1

๐Ÿ› ๏ธ 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.
  1. Plan on paper: what happens when pressed? And what happens when released?
  2. Use if โ€ฆ else inside loop.
  3. In the if part: turn on the LED and play the notes.
  4. 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.

๐Ÿงฉ A light with every note
Blocks: loop โ€” repeats forever
Light and tune
Light and tune
โœ๏ธ Practise
Build the music box.
โœ๏ธ Practise here in the lessonor open the lab in a new page โ†—

๐ŸŽฏ Challenge yourself

Easy

When pressed: the LED lights up and plays 3 notes.

๐Ÿ‘€ Show the solution
๐Ÿงฉ Solution
Blocks: loop โ€” repeats forever
In the lab
In the lab

Result: light and a tune.

Medium

Not pressed: the LED blinks slowly, waiting. Pressed: it plays.

๐Ÿ‘€ Show the solution
๐Ÿงฉ Solution
Blocks: loop โ€” repeats forever
In the lab
In the lab

Result: it waits, then plays.

Hard

A long music box: 5 notes, and the LED blinks with every note.

๐Ÿ‘€ Show the solution
๐Ÿงฉ Solution
Blocks: loop โ€” repeats forever
In the lab
In the lab

Result: a tune and a blinking light.

Finished the lesson? Mark it so your progress counts.