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:
|
Dance Activity 1 Hokey Pokey Song |
Activity Steps:
|
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 speedThe 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:
|
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...doThe 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 valuesThe 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:
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 sensorThe 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:
|
Your Turn – Dance the Hokey Pokey |
|
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. |