agsdix-fas fa-child

Play ♪ Happy Birthday ♪ with colored lights

Let’s synchronize colored lights while playing the song “Happy Birthday.”

Info Outline Icon
Basic Activity; Timing; Variables; Multiple Device Control; Lights; Musical Notes.

What are we going to do?

Are you a teacher?

Lesson plan

Courses

  • Grades 3-12
  • 3rd Grade – 12th Grade Courses

Materials

  • Cellphone, tablet, or computer
  • Internet connection

Description

In this activity, students can have an introductory experience with Protobject, learning visual programming and computer science with a device in a safe and playful manner.

Educational Objectives

  • Understand the concept of sequence of steps.
  • Create a technological object (prototype) using a device.
  • Identify relationships between technology and the surrounding world.
  • Evaluate personal and others’ work in individual or team projects.
  • Discuss and reflect on ideas for improvement.

Start (10 minutes)

Welcome the students to the class and briefly introduce the day’s activity: “Today, we will learn how to prototype music with lights.”

We will start the class by providing technical knowledge to the students for meaningful learning of the practical activity.

To kick off the class, we can begin with a question:

Do you remember what we learned about playing musical notes and lighting up colored lights?

 

You can let the students propose their answers and then complement with the correct response.

Now, we will learn how to synchronize those notes with colored lights to create an exciting multisensory experience.

Synchronize means performing two or more actions at the same time or simultaneously.

For this, we will use the concept of a variable, do you know what that is?

You can let the students propose their answers and then complement with the correct response.

A variable is like a box that holds a value that can be reused in different parts of the project.

For example, we could define a variable called “time” (All variables must have a name!) with a delay value.

Then, this variable can be used to set the delays for all the notes at once.

This way, by changing the “time” variable once, it will automatically reset the delays for all the notes.

Next, we will see practically how a variable can be used to easily change the speed of a melody along with colored lights.

Finally, to initiate the prototyping process and make them feel like active participants in their learning, ask them:

Do you want to learn how to prototype music with lights?

Development (20-30 minutes)

Connect our equipment to the Protobject platform. For this exercise, we will use PLAYKEYBOARD and also LAMP.

Remember to experiment with it yourself before asking the students to experiment with Protobject. This way, you can anticipate any questions that may arise from the students.

First, let’s set the variable “time”; in this case, we’ll call it “TIME” and set it to 800.

Then, I’ll instruct the keyboard to play a note and the lamp to light up with a particular color for this specific note. For example, we’ll start with the note DO4 and the color orange.

Finally, we’ll bring in the “time” variable, which will introduce a delay in milliseconds based on what we determined earlier. For example, this will be 800 because that’s the value we assigned to the variable.

Now, repeat these steps for the entire song: do4, do4, sol4, sol4, la4, la4, sol4, fa4, fa4, mi4, mi4, re4, re4, do4.

This way, if you want to change this timing in the future, you only need to change the initial variable, and it will automatically update all instances of it.

To test the prototype, instruct the students to click on the activation button.

Congratulations!

Conclusion (5-10 minutes)

Now that you have prototyped music with synchronized lights using Protobject, challenge your students with a question:

What if we wanted to create other synchronized lights?

Try adding more lights and experimenting with different colors!

To solve the challenge posed, we would need to create another Lamp component on another smartphone and add its light blocks in the same positions as the others. This way, they will light up simultaneously.

agsdix-fas fa-book-reader

Learn

Let’s synchronize sounds and colorful lights to create a multisensory experience!

In the previous activities, we learned how to play musical notes and turn on colored lights. Now, we are going to learn how to synchronize these notes with colored lights to create an exciting multisensory experience.

Synchronizing means performing two or more actions at the same time or simultaneously.

Variables and wait (time)

In the previous activity, did you try to change the speed of the melody? To do so, you would have had to change all the delays of all the notes, right?

It’s inconvenient, isn’t it? Is there a better alternative? Yes, there is: by using variables!

What is a variable?

A variable is like a box that holds a value that can be reused in different parts of the project.

For example, we could define a variable called “time” (all variables must have a name!) with a delay value. Then, you can use this variable to set the delays for all the notes at once.

This way, by changing once the variable “time,” the delays for all the notes will automatically be reset. Next, we’ll see in practice how you can use a variable to easily change the speed of a melody along with colored lights.

Make

Let’s create a prototype that allows us to play ♪ Happy Birthday ♪ along with colored lights on the smartphone.

First, we’ll add two devices that enable us to (1) play musical notes and (2) turn on lights.

1

Press Add Device and select MusicalKeyboard.

2

Press DevicesAdd Device and select Lamp.

3

Remember that if you don’t have smartphones to scan the QR codes, you can press Open in this window to open the components on the same computer.

Plus Square Icon

Suggestion: In Protobject, you can add more components on the same smartphone by pressing the SCAN button as many times as you need.

Code composition

Click on question circle icon to open the comments that explain the code.

The multiplication blocks are located in the Mathematics category.

Plus Square Icon

Experiment: Try changing the value of the “time” variable to alter the speed of the music.

agsdi-bulb-options

Reflect

What if we wanted to create other synchronized lights?

Try adding more lights and experimenting with different colors!

Plus Square Icon

Add a new Lamp component on another smartphone and combine the new light with what you’ve done.

In the next activity, we will introduce the concept of the main loop, which allows us to repeat sequences indefinitely.