5
Windmill We will create a windmill animation Add a ‘forever’ loop Add a series of LED images with short pauses between to shw a rotating windmill

robjonescowley.files.wordpress.com€¦  · Web viewWindmill. We will create a windmill animation. Add a ‘forever’ loop. Add a series of LED images with short pauses between

  • Upload
    hanga

  • View
    215

  • Download
    0

Embed Size (px)

Citation preview

Windmill

We will create a windmill animation

Add a ‘forever’ loop

Add a series of LED images with short pauses between to shw a rotating windmill

Now we will replace the forever with a ‘while True loop’

This lets the animation run as long as a condition is True

Create a new variable. Call it rotating. Set rotating to true

This means that this variable is ‘on’

Change the while ‘true’ to while ‘rotating’

Therefore whilst the variable ‘rotating’ is true (or on), then the program in the while loop will run

Now add a ‘on button A pressed loop’

Add in the rotating variable and set it to false

Now the variable ‘rotating’ is true (or on) and the windmill animation in the while true loop runs

When the button A is pressed, the variable ‘rotating’ is false (or off) and the windmill animation in the while true loop stops running

Challenge

1. Change the program so that button A stops the animation2. Change the program so that button B starts the animation

Answers