ุงู†ุชู‚ู„ ู„ู„ู…ุญุชูˆู‰
Robo EgyptRobo Egypt
โ˜ฐ Course contents
Robo Block: home
0. Lab tour1
1. Getting started5
2. Motion5
3. Looks and sound5
4. Events4
5. Loops5
6. Conditions and sensing4
7. Variables and randomness4
8. Project: the โ€œCatch Roboโ€ game3
9. Messages: characters talk to each other4
10. Clones: one character, many copies4
11. My Blocks: make a new block3
12. Operators and time4
13. The pro project: a jumping game4

๐Ÿ› ๏ธ Section project: a little piano

Section 3: Looks and soundLesson 3.4 ยท โฑ 12 min

Turn the keyboard into a piano: every key plays a note, and Robo dances with the music.

๐ŸŽฏ Project goal
When you press the keys 1, 2, a and b you hear C, D, E and F, and each time Robo switches his costume.

Steps

  1. Drag the block when key pressed and choose the key 1.
  2. Put next costume under it, then play note (60).
  3. Do the same for the keys 2, a and b with the notes 62, 64 and 65.
  4. Play a tune with the keys.
๐Ÿงฉ Key 1: C
Blocks: when (1) key pressed, next costume, play note (60) for (0.5) beats
๐Ÿงฉ Key 2: D
Blocks: when (2) key pressed, next costume, play note (62) for (0.5) beats
๐Ÿ’ก Tip
Copy the script by right-clicking it and choosing โ€œDuplicateโ€, then change only the key and the note.

๐Ÿ“Œ Another example: two more keys

The key d plays E, the key b plays F, and every press switches Robo's costume.

Blocks: when (d) key pressed, next costume, play note (64) for (0.5) beats
Blocks: when (b) key pressed, next costume, play note (65) for (0.5) beats
We pressed d
We pressed d
We pressed b
We pressed b
โœ๏ธ Practise
Build the whole piano here: a key for every note from C to G.
โœ๏ธ Practise here in the lessonor open the lab in a new page โ†—

๐ŸŽฏ Challenge yourself

Easy

Make the space key play G, and Robo says โ€œGโ€.

๐Ÿ‘€ Show the solution
Blocks: when (space) key pressed, play note (67) for (0.5) beats, say (G) for (1) seconds
After pressing space
After pressing space
Medium

Make the flag play a ready tune of 5 notes, then Robo says โ€œMy tune ๐ŸŽถโ€.

๐Ÿ‘€ Show the solution
Blocks: when ๐Ÿšฉ clicked, play note (60) for (0.5) beats, play note (62) for (0.5) beats, play note (64) for (0.5) beats, play note (62) for (0.5) beats, play note (60) for (0.5) beats, say (My tune ๐ŸŽถ) for (2) seconds
The result on the stage
The result on the stage
Hard

The key a plays C and makes Robo 10 bigger, and the key d plays D and makes him 10 smaller. We pressed a, then a, then d: what is the size?

๐Ÿ‘€ Show the solution
Blocks: when ๐Ÿšฉ clicked, set size to (100) %
Blocks: when (a) key pressed, play note (60) for (0.5) beats, change size by (10)
Blocks: when (d) key pressed, play note (62) for (0.5) beats, change size by (-10)
The size is 110
The size is 110
Finished the lesson? Mark it so your progress counts.