Lesson 18: Dance Party
In this lesson, students will program their own interactive dance party. This activity requires sound as the tool was built to respond to music.
This lesson introduces the core CS concepts of coding and event programming (using blocks).
Getting Started (5 minutes)
Activity (30-45 minutes)
Wrap Up (5 minutes)
Assessment (2 minutes)
Students will be able to:
- Develop programs that respond to timed events
- Develop programs that respond to user input
- Create dance animations with code
- Play through the puzzles to find any potential problem areas for your class.
- Make sure every student has a journal.
- Consider the need for headphones. This activity relies on sound.
Heads Up! Please make a copy of any documents you plan to share with students.
For the Teachers
For the Students
- Dance Party Project Guide - Worksheet
- code - (v) to write code, or to write instructions for a computer.
- Event - An action that causes something to happen.
- Program - An algorithm that has been coded into something that can be run by a machine.
Getting Started (5 minutes)
Setting the Stage
Welcome students to class and very briefly introduce the day’s activity.
If you have time and would like to prepare your students with an unplugged activity, consider delivering "Dance Party: Unplugged" before this lesson. This brief lesson introduces students to the idea of events triggering different dance moves.
Today we're going to do something really creative. What's your favorite way to be creative?
Encourage students to share the ways they express creativity, such as with art, dance, music, writing.
Explain that today we're going to be creative with our code. Just like choosing which type of colors of paint to use, or what kinds of words you write with can be express creativity, choosing what code you write and how people interact with it can be an opportunity to express your creativity too!
Get up and dance: Announce to the class that today we're going to see how we can combine coding with dancing in a creative way. Ask your kids to floss, dab, or do a creative dance move of their own for 10 seconds to get them in the mood. You can play a song from this Spotify Playlist (all ages) to help kick things off. Capture your class's moves on video.
Activity (30-45 minutes)
Code Your Own Dance Party
This tutorial features songs from popular artists. To get a preview of the song list in this tutorial, check out this Spotify Playlist. We are using radio-safe versions of all songs and for students under 13, we limit the music to this filtered list Spotify Playlist (all ages). If you would like to use the filtered list with older students, you can share this link with your classroom.
Level by Level Support
- Drag the red
make a newblock from the toolbox on the left to the workspace on the right. Connect it inside the
- You have now written your first program. Make sure to press Run to see what happens. You should hear music and see a character start to move in the display area.
- The green blocks are event blocks. These blocks start a new sequence of code and do not need to be connected inside the
- Connecting the purple block under the green event block should make the character perform a dance move after the number of measures you indicate.
- Make sure to bring out a second green event block. You should have a
after 4 measuresblock and a
after 6 measuresblock in your workspace. Both should have purple block connected underneath.
- Drag out the
set background effectblock.
- This block can be connected inside
setup, under an event block, or in both places!
- With the right code, you should see the dancer cycle through a different move every 2 measures.
- Make sure there is a purple
do foreverblock connected inside the
every 2 measuresblock.
- Make sure the
do foreverblock is set to either (Next), (Previous), or (Random). Otherwise, the dancer will just perform the set move repeatedly.
- Be careful to avoid putting the red
make a newblock inside the
every 2 measuresblock. This will cause your program to create multiple identical dancers at the same location.
- Many students will be familiar with the idea that you can make something seem to be further away by drawing it a smaller scale. In this level, you'll create this effect by making the two dancers on the ends smaller.
- It is important to make sure that the teal
setblock is placed somewhere in the program after the dancer has been created. To solve this puzzle, place a
set backup_dancer2 size to 50block somewhere under the
make a new robot called backup_dancer2block.
- As with the previous level, make sure to only use the
set tint to (color)block after you have the made the dancer in your program. For example, placing it as the first step in the
setuparea of your program will have no effect.
- Computer science allows to process input information into interesting types of output. In this level, students can explore how a dancer's properties can be updated automatically based on the actual sound of the music.
By this point in the lesson you may notice that the instructions are less prescriptive. Encourage students to be creative and explore the new blocks that are introduced. From this point on student code is not checked for correctness in order to encourage experimentation instead of solving a specific task.
- These levels are about making the dance interactive. Try out the new
when pressedevent to make the dancers respond to key presses.
- You can use the arrow keys on your computer keyboard or click the orange buttons under the display area.
- Note that the code students write in these levels is not checked for correctness. This means they will always pass the level, even if they do not change the program. Encourage students to determine for themselves whether the code is doing what they expect before moving on.
- The top six blocks in this tool box look familiar but all work in a different way. Instead of creating or controlling one dancer, they work with groups of dancers.
- Like the previous levels, code is not checked for correctness here. Students should feel free to experiment with groups in ways that are interesting to them.
- This last level is very open-ended. The tutorial itself is designed to give students ample time to keep working on their own dance.
- Encourage Sharing: If students have cell phones with a data plan they can quickly text a link to their projects to their own phone or a friend's. If your school policy allows it, encourage them to do so here.
- Encourage Creativity: Creativity is important throughout this lesson, but this is true here more than anywhere else!
Wrap Up (5 minutes)
- Pose a prompt that has multiple answers such as “What is something you enjoyed about today's activity?” or “What is the connection between creativity and computer science?"
Assessment (2 minutes)
Ask students to add their “Whip Around” sticky notes or note cards to your "Computer Science" mind map on their way out the door. Try to populate the board with lots of great ideas about what CS is and why it matters.
Let's have a dance party!
make a new block into the workspace, and connect it inside the
setup block to create your first dancer.
- You can also click the lightbulb to the left if you want more information or extra challenges.
Let's get this moose dancing!
Drag out the new_dancer do floss block onto the workspace. Connect it underneath the after 4 measures event block. Your dancer should start a new move after the fourth measure.
Measures are used to count time in music. In this tutorial, a measure is four beats long.
Now we're grooving!
Add an after 6 measures event block to your workspace. Make the dancer start a new move after 6 measures.
This dance needs some flash!
Look for a new block in your toolbox that adds a background effect behind your dancer. Watch the effects change in time with the music!
Use another new block to make the dancer change moves every 2 measures!
(Random)tells the dancer to perform a different move every time the code is run.
We need more dancers!
Create a backup dancer called
backup_dancer1 to dance with the cat.
Every dancer has a set of properties that control what it looks like.
You can make it look like a dancer is in the background by making their size smaller. Can you make both backup dancers the same size?
Dancers have a "tint" property that can add a layer of color. Try changing the tint of one of your dancers. * Tints will mix the color you choose with the colors of the dancer.
Now we know how to change a dancer's properties. We can also make the same properties automatically respond to the music using this block: right_unicorn begins following bass
This program uses the music's "bass" volume (the low sounds) to control one dancer's height. Can you make the other dancer respond to the music too?
The when up pressed event block lets you run code when the up arrow is pressed.
You might change the dance move, change a dancer's properties, or do a quick move just once. Be creative and look out for new blocks!
It's time for a dance-off! The Cat dabs when you press the left arrow key. Make the Robot "drop" once when you press the right arrow key, and "clap" once when you press the up arrow key.
Use the keys to get the Robot to do the drop-clap-drop-clap as fast as you can!
Check out this block:
Make 6 new ducks in a circle
Now you can create a bunch of dancers at once! Try using some of the "all ducks" blocks to write code that will make all of the ducks dance together.