web viewchange the program so that the second row where y=3 comes on ... change the direction of the...

4
Strobe Light We will get a strobe light to display on the microbit Add an ‘forever’ loop Add a ‘i from 0 to 4’ block. This will create numbers 0,1,2,3,4 in turn These numbers will be our x coordinate on the LED Display Change i to x so it makes more sense Add a plot x y Make the x cordinate = x This will change from being 0 to 1 to 2 to 3 to 4 y will stay as 0

Upload: vukhue

Post on 16-Mar-2018

215 views

Category:

Documents


1 download

TRANSCRIPT

Strobe Light

We will get a strobe light to display on the microbit

Add an ‘forever’ loop

Add a ‘i from 0 to 4’ block.

This will create numbers 0,1,2,3,4 in turn

These numbers will be our x coordinate on the LED Display

Change i to x so it makes more sense

Add a plot x y

Make the x cordinate = x

This will change from being 0 to 1 to 2 to 3 to 4

y will stay as 0

The lights along row 1 (where y = 0) light up one at a time but so quickly that they appear all at once

Add in a pause to slow this down

Now each of the LEDs come on at the following (x,y) coordinates (0,0), (1,0), (2,0), (3.0), (4,0) one at a time

Challenge

1. Change the program so that the second row where y=1 comes on one at a time2. Change the program so that the second row where y=2 comes on one at a time3. Change the program so that the second row where y=3 comes on one at a time

Now we need to get y to change from being 0 to 1 to 2 to 3 to 4

We add in another for i from 0 to 4 loop

Change i to y so that it makes more sense

Now x will change from being 0 to 1 to 2 to 3 to 4 and

y will change from being 0 to 1 to 2 to 3 to 4

If we plot x and y coordinates

It will cycle through all of the LEDs

Challenge

1. Clear the screen before the forever loop repeats2. Move the ‘clear screen’ so that one LED appears at a time3. Change the direction of the strobe so that it goes across rows rather than down columns

Answers