Dance Activities: Do the Hokey Pokey

Yes, that is right…your Scribbler CAN dance. Besides being kind of cute, the Scribbler can really shake a leg…or wheel as the case may be. By combining music and movement and some creative programming methods, we can have Scribbler run a pretty advanced dance routine. 

In these activities we will create the music for scribbler to play the Hokey Pokey song. Then we will add movements so it dances the Hokey Pokey with the music. We will learn how to control the start of the routine by pressing the reset button. You will be able to dance the Hokey Pokey with your robot, and finally, the class will put all the robots together and let them dance!

Here's what we will do:

Pre-Activity Check List:

    • Reviewed the materials for this lesson.
    • Watched the concept and activity videos.
    • Scribbler S3 Robot is fully charged (blue light is on).
    • Scribbler is connected to a computer via USB cable and wheels are up in ‘garage mode’.
    • An area where you can place the Scribbler to dance.
    • Started BlockyPropClient software on the computer.blocklypropclient
    • Have https://blockly.parallax.com website open in Internet Browser and have logged in.
    • Reviewed the Sound blockly reference.
    • Download Hokey Pokey music sheet (Note: our notes won't be exactly as shown here).

Dance Activity 1 Hokey Pokey Song

Activity Steps:

  1. Start a new Project.
    • Project Name: Hokey Pokey Activity 1
    • Board/Device type: Scribbler Robot
    • Description: Hokey Pokey Song
    • Sharing: Private
  2. Add Comments.
    • Click Control, choose Add Comment and Drag onto Worksheet
    • Type into grey area ‘Hokey Pokey Activity 1’
    • Add another Comment below first one  and type “Programmer: “ and your name.
    • Add a third Comment and type in "Hokey Pokey Song".
  3. Add a comment block and type in Hokey Pokey
  4. Add another comment block and type in "You put your right wheel in"
  5. Add 6 play note blocks
    • block 1 play a middle D for a quarter note at a medium volume
    • block 2 play a middle E for a eighth note at a medium volume
    • block 3 play a middle D for a eighth note at a medium volume
    • block 4 play a middle G for a quarter note at a medium volume
    • block 1 play a middle G for a quarter note at a medium volume
    • block 1 play a middle G for a half note at a medium volume
  6. Add a wait block
    • Put the number 4 into the wait block
    • Change the wait block to tenths of a second
  7. Add a comment block and type in "You put your right wheel out"
  8. Add 6 play note blocks
    • play a middle D for a quarter note at a medium volume
    • play a middle E for a eighth note at a medium volume
    • play a middle D for a eighth note at a medium volume
    • play a middle G for a quarter note at a medium volume
    • play a middle G for a quarter note at a medium volume
    • play a middle G for a half note at a medium volume
  9. Duplicate the wait block
  10. Add a comment block and type in "You put your right wheel in"
  11. Add 6 play note blocks
    • play a middle D for a quarter note at a medium volume
    • play a middle E for a eighth note at a medium volume
    • play a middle D for a eighth note at a medium volume
    • play a middle G for a quarter note at a medium volume
    • play a middle G for a quarter note at a medium volume
    • play a middle G for a half note at a medium volume
  12. Duplicate the wait block
  13. Add a comment block and type in "and you shake it all a-bout"
  14. Add 7 play note blocks:
    • play a middle E for a quarter note at a loud volume
    • play a middle D for a quarter note at a loud volume
    • play a middle F#/Gb for a eighth note at a loud volume
    • play a middle F for a eighth note at a loud volume
    • play a middle F#/Gb for a eighth note at a loud volume
    • play a middle F for a eighth note at a loud volume
    • play a middle F#/Gb for a eighth note at a loud volume
  15. Duplicate the wait block
  16. Add a comment block and type in "You do the ho-key po-key and"
  17. Add 8 play note blocks
    • play a middle D for a quarter note at a loud volume
    • play a middle F#/Gb for a eighth note at a loud volume
    • play a middle F for a eighth note at a loud volume
    • play a middle F#/Gb for a eighth note at a loud volume
    • play a middle F for a eighth note at a loud volume
    • play a middle F#/Gb for a eighth note at a loud volume
    •  play a middle F#/Gb for a eighth note at a loud volume
    •  play a middle F for a eighth note at a loud volume
  18. Add a comment block and type in "you turn your-self a-round"
  19. Add 6 play note blocks
    • play a middle D for a eighth note at a loud volume
    • play a middle F#/Gb for a eighth note at a loud volume
    • play a middle F for a eighth note at a loud volume
    • play a middle F#/Gb for a eighth note at a loud volume
    • play a middle F for a quarter note at a loud volume
    •  play a middle F#/Gb for a quarter note at a loud volume
  20. Duplicate the wait block
  21. Add a comment block and type in "That's what it's all a-bout"
  22. Add 6 play note blocks.
    • play a middle D for a eighth note at a loud volume
    • play a middle D for a quarter note at a loud volume
    • play a middle D for a eighth note at a loud volume
    • play a middle E for a quarter note at a loud volume
    • play a middle F#Gb for a quarter note at a loud volume
    • play a middle G for a quarter note at a loud volume
  23. Duplicate the wait block
  24. Add a Stop driving block
  25. Save your project.
  26. Upload the code to the robot and run it
  27. Did it work as you expected?  If not, make changes and try again until it smoothly plays the hokey pokey music.
  28. Try changing the value of the wait time to see how more or less time can make a difference in how the song plays.
hokey pokey activity 1

Dance Activity 2 – Add moves for Hokey Pokey

Now let's add some moves to the music. We will also simplify the code by creating some functions for different parts of the music and then running the functions from the main routine.  

We will use the drive speed block to control the robot's movement. As a refresher, here is a definition of the drive speed block:

drive speed

The drive speed block sets the left and right motor speeds as percentages of top speed. Negative values are for backward travel, positive values for forward travel. When a value is outside of the -100 to 100 percent range, the block will use the closest value, either -100 or 100 percent. If a duration is specified, in milliseconds, the Scribbler robot will not run the next block command until the Scribbler robot stops moving. If the duration is over the maximum range of 65,535 milliseconds, the block will use a duration of 65,535 milliseconds. If the duration is either unspecified, at the default of zero, out of range, or in the negative, the Scribbler robot will continue running block commands while running the motors, until the stop driving command is used.

Your challenge is to figure out what does shaking a leg look like when the Scribbler robot does it and translate that to moves using the drive speed block. 


Activity 2 Steps:

  1. Open My Projects and select Hokey Pokey Activity 1 (if not already open). 
  2. From the Menu choose Save the Project as 
    • Project Name: Hokey Pokey Activity 2
    • Board/Device type: Scribbler Robot
    • Description: Add moves for Hokey Pokey
    • Sharing: Private
  3. Create a new function
    • Name You put your right wheel in
    • Move the blocks from comment block "You put your right wheel in" to the wait 4 tenth of a second block into the new function.
    • Add a drive speed block under the comment block
      • left motor: 0
      • right motor: 50
      • for (milliseconds, 0 is continuous): 0
    • Add a run function "you put your right wheel in" to the main routine.
  4. Create new functions for:
    • You put your right wheel out
    • and you shake it all a-bout
    • You Turn your-self a-round
    • That's what it's all a-bout
  5. Move the code for each section into the functions.
  6. Add drive speed block to function "You put your right wheel out" that moves the right wheel backwards.
  7. Add drive speed blocks to function "That's what it's all a-bout" that moves the right wheel forward then backwards. (hint: put a drive speed block inbetween each note block)
  8. Add drive speed block to function "You Turn your-self a-round" that Turns the robot 180 degrees.
  9. Add drive speed blocks to function "and you shake it all a-bout" that moves both wheels forward then backwards. (hint: put a drive speed block inbetween each note block)
  10. Add run functions for each of the functions to the main routine.
    • You put your right wheel out
    • and you shake it all a-bout
    • You Turn your-self a-round
    • That's what it's all a-bout
  11. Save your project.
  12. Upload the code to the robot and run the project code
  13. Did it work as you expected?  If not, make changes and try again until it smoothly does the hokey pokey routine with moves coordinated with the music.
hokey pokey activity 2

Dance Activity 3 – Control the start time

Now let's add the ability to control when the robot starts doing the dance routine. Remember when we ran the Demo programs? We were able to start each one by pressing the Reset button a certain number of times.  We can use that trick in our programs. We can check to see if the reset button was pressed, and find out how many times it was pressed and then take some action. 

We will use an If Condition block and put inside of it a compare values block. The two values we want to compare are the reset button presses and the number 2.  We want to know if the button was pressed 2 times. 

if...do

The if...do block is for decision-making: if the condition inserted at right is true, the enclosed code in the do section will execute. If the condition is not true, the do section will be skipped over and not executed.

The if...do block is a mutating block, indicated by the gear that can be clicked. It allows the block to include multiple “else” and “else if” conditions. If the first condition is not true, its enclosed code will be skipped and the next else if or else conditions will be evaluated and executed if true, before exiting the outer block.

compare values

The compare values block compares two values and creates an Equality or Inequality math statement. Two inserted values results in a Boolean logic value of 1 if the statement is true, and 0 if it is false. Notice that there are two puzzle shapes. That means we can choose blocks that look like puzzle shapes and insert them and compare their values. Choose the operation or the type of comparison from the dropdown menu:

  • = equal to
  • ≠ not equal to
  • > greater than
  • < less than
  • ≥ greater than or equal to
  • ≤ less than or equal to

The compare values is often used with the If condition to create logic like: If Number of button presses is greater than 3 then do these things, otherwise do these other things. That would look like:

If Number of button presses > 3

do this block

and this block

ELSE

do this block

and this block. 

What is Boolean logic?  Named after the nineteenth-century mathematician George Boole, Boolean logic is a form of algebra in which all values are reduced to either TRUE or FALSE. Boolean logic is especially important for computer science because it fits nicely with the binary numbering system, in which each bit has a value of either 1 or 0. Another way of looking at it is that each bit has a value of either TRUE or FALSE.

button sensor

The button sensor block monitors and returns the number of times (0-8) the blue Scribbler reset button is pressed in succession.  You can use it to control actions that you want the robot to take.  For example, you could have the robot stop one particular dance move and start the next one when the button is pressed twice. You can think of this block as a special type of variable. It has a number stored inside, and we can compare that number to a value. 

Activity 3 Steps:

  1. Open My Projects and select Hokey Pokey Activity 2 (if not already open). 
  2. From the Menu choose Save the Project as 
    • Project Name: Hokey Pokey Activity 3
    • Board/Device type: Scribbler Robot
    • Description: Control the start time
    • Sharing: Private
  3. Now let's add code to check to see if the reset button was pressed 2 times.
    • From the Control section, drag out an if block and place it under the first three comment blocks in the main program
    • From the Math section, drag out a math equation block and connect it to the if block. From the drop down,  set it to equal =
    • From the Sensor section drag out a reset button block and place it in the left of the equation
    • From the Math section, drag out a number value block and place it in the right of the equation and set it to 2.
  4. Move all of the blocks under the if block to inside the if block, so they only run if the condition is true.
  5. Save your project.
  6. Upload the code to the robot and run the project.
  7. Try pressing the Reset button twice. Did it work as you expected?  If not, make changes and try again until it only starts and plays the Hokey Pokey when the reset button is pressed.
hokey pokey activity 3

Your Turn – Dance the Hokey Pokey

  • Make a copy of your Dance program from Activity 3 and name it Hokey Pokey Your Turn
  • Evaluate your code. Are any of the blocks of code the same?  Can you make it more efficient?
  • Add some lights flashing to your routines when the robot moves and turns about.
  • Now it is time to Dance the Hokey Pokey with your robot.  
  • Put the robot in place on the floor and press the reset button twice.
  • Sing the Hokey Pokey song and dance as it plays music and moves and flashes lights.

Your Turn – Whole Class Dance Routine

Everyone put the robots together in a circle, coordinate the start time to press the button, and let the robots dance together.

Copyright 2017 Interactive Media Publishing, All rights reserved