rotation animation quiz

Learn how to create a rotating image with a while loop.

Name

Directions

Use this activity document to guide your work in the rotation animation tutorial.

Answer the questions while completing the tutorial. Pay attention to the dialogues!

1. What is a “ variable”?


2. Write the code to create a variable called foo that stores a boolean and initialize it to false.


3. Explain why you use a while loop with a variable

let rotating = true;
while (rotating) {
    basic.showLeds(`
        . . . . .
        . . . . .
        . . # . .
        . . . . .
        . . . . .
        `)
    basic.showLeds(`
        . . . . .
        . . . . .
        . . . . .
        . . . . .
        . . . . .
        `)
}


4. Draw the areas on the micro:bits to illustrate the code below. Explain why you chose to draw in those areas.

basic.showLeds(`
        . . # . .
        . . # . .
        . . # . .
        . . # . .
        . . # . .
        `)
basic.showLeds(`
        . . . . .
        . . . . .
        # # # # #
        . . . . .
        . . . . .
        `)
basic.showLeds(`
        . . . . #
        . . . # .
        . . # . .
        . # . . .
        # . . . .
        `)
basic.showLeds(`
        . . . . #
        . . . # .
        . . # . .
        . # . . .
        # . . . .
        `)