let nn = 0 basic.showIcon(IconNames.Happy) basic.forever(function () { nn = randint(1, 3) basic.showNumber(nn) if (nn <= 1) { pins.digitalWritePin(DigitalPin.P0, 1) } else { if (nn <= 2) { pins.digitalWritePin(DigitalPin.P1, 1) } else { pins.digitalWritePin(DigitalPin.P2, 1) } } basic.pause(2000) pins.digitalWritePin(DigitalPin.P0, 0) pins.digitalWritePin(DigitalPin.P1, 0) pins.digitalWritePin(DigitalPin.P2, 0) })