---
title: "Dance Dance Rover-lution"
date: "2022-03-13"
categories: ["Activities"]
tags: ["Iteration", "Functions", "Buzzer", "Motors", "LEDs"]
codingSkills: ["Iteration", "Functions"]
roverConcepts: ["Buzzer", "Motors", "LEDs"]
excerpt: "Time to boogie down with some programming."
featuredImage: "/images/resources/dance-dance-rover-lution.png"
---

** **

Let’s hold a dance contest in the classroom for rovers to compete in! Students can program the motors to perform dance moves, use LEDs and add sounds to add flair to their dance. Students are encouraged to use loops and functions to simplify their code. Points will be awarded to students who make good use of the rover’s tools and well written code.

![](/images/content/1292fa-dance-dance-roverlution.png)

### Setup

When running this exercise we like to group students to create collaborative dance routines involving multiple rovers. You can pick group sizes that work for your classroom. We find 4-5 students working together to create a dance routine involving 3 rovers is a good sizing. The rest of the setup depends on what you have available in the classroom. You could add obstacles or props to make the performance more interesting.

### Here’s Our Approach

![](/images/content/159e0f-dance-dance-roverlution-answer.png)

Example code

#### Stage 1

There isn't a single correct solution for this challenge as each student will program their robots differently. Regardless of solution, we encourage students to use functions to organise their code. The example here shows how you can use a function to create a dance move and keep code organised.

#### **Stage 2**

Function blocks work in pairs. There is a block that holds all the instructions, and a small single block that calls upon those instructions. For this example, from the functions category we drag in a function block and name it FancySpin. Inside our function block we place our dance moves. These blocks inside the function is what will run when we call the function. With this example we will set some LEDs, play some sounds and make the rover spin around.

#### **Stage 3**

From our start block we are going to add a loop block that runs twice. Inside the loop we will call the FancySpin function to run by adding the FancySpin block. This means all of the blocks inside of our FancySpin function will be played twice.
