View on GitHub

rando-led

A MakeCode project

Random lights

Step 1

Add a ||led:toggle|| block under the ||basic:forever|| event.

basic.forever(function () {
    led.toggle(0, 0)
})

Step 2

Insert a block to generate a random x LED position to toggle, a nubmer between 0 and 4.

basic.forever(function () {
    led.toggle(Math.randomRange(0, 4), 0)
})

Step 3

Insert a another block to generate a random y LED position to toggle, a nubmer between 0 and 4.

basic.forever(function () {
    led.toggle(Math.randomRange(0, 4), Math.randomRange(0, 4))
})