Rock! Paper! Scissors!

Important! Before you get started, make sure your micro:bit is connected to your computer: Connect your micro:bit


⏱️ Step 1: Display a countdown… 3… 2… 1

input.onButtonPressed(Button.A, function () {
    basic.showString("3")
    basic.pause(1000)
    basic.showString("2")
    basic.pause(1000)
    basic.showString("1")
    basic.pause(1000)
})

🎚️ Step 2: Make a new variable

Call the variable choice.


🎲 Step 3: Set the variable to a random number

Add this command to the code you already have:

choice = randint(1, 3)

✊✋✌️ Step 4: Display the icon for the chosen thing

Finally, add this:

if (choice == 1) {
    basic.showLeds(`
        . . . . .
        . # # # .
        . # # # .
        . # # # .
        . . . . .
        `)
}
if (choice == 2) {
    basic.showIcon(IconNames.Square)
}
if (choice == 3) {
    basic.showIcon(IconNames.Scissors)
}

🤔 Challenges