Decimal Vault PIN

Up to this point, the scripts have used simple PINs with three or four binary digits.  If the scripts instead use decimal digits, the increase in possible combinations improves the security by making it more time consuming to crack the PIN with brute force.

In this activity, you will use scripts that repeat what you’ve done up to now, but with decimal digits in the 0 through 5 range.  Since each digit has six possible values, the number of combinations is:

6 x 6 x 6 = 63 = 216 combinations


  • If you are part of a class, and have been assigned a channel, make sure to adjust the script’s channel=7 to your assigned channel before you save and flash the scripts.
  • Enter, save, and flash the transmitter decimal_pin_pad_transmitter script into the PIN Pad Transmitter micro:bit.
  • Enter, save, and flash the receiver decimal_bank_vault_receiver script into the Bank Vault Receiver micro:bit.  Receiver Script (decimal bank vault) is below the Transmitter Script (decimal PIN pad).
  • Before continuing, take a look at the decimal_bank_vault_receiver script’s pin = '324' statement.  This is the PIN number you will have to enter into the PIN Pad Transmitter micro:bit’s A/B buttons to gain access.  

Transmitter Script: decimal_pin_pad_transmitter

# decimal_pin_pad_transmitter

from microbit import *
import radio


pin = ''
n = 0

while True:

    x = len(pin)
    if button_a.was_pressed():
        if n < 5:
            n += 1
            if n is not 0:
                y = n - 1
                display.set_pixel(x, y, 9)
            for y in range(0, 5):
                display.set_pixel(x, y, 0)
            n = 0
    if button_b.was_pressed():
        pin += str(n)
        n = 0
        if len(pin) == 3:
            pin = ''


Receiver Script: decimal_bank_vault_receiver

# decimal_bank_vault_receiver                 # <- change

from microbit import *
import radio
import random


pin = '324'                                   # <- change

while True:          # <- change
    message = radio.receive()
    if message:
        pin_entered = str(message)

        if pin_entered == pin:
            radio.send("Access granted.")
            for n in range(4):
            radio.send("Access denied.")



Again, let’s check to make sure each micro:bit is running the correct script.  

  • Verify that the decimal PIN Pad Transmitter micro:bit has no lights on.
  • Verify that the decimal Vault Receiver micro:bit shows a square in the center of its display.

Now, as you press and release the A button, LEDs will light from the top downward.  No lights in a column means 0.  One light means 1, and so on, up through five lights for 5.

  • Enter the correct key like this: A A A B A A B A A A A B.
  • Verify that two things happened:
    • The decimal PIN Pad Transmitter micro:bit scrolls 3 2 4 across its display.
    • The decimal Bank Vault Receiver displays a flashing check mark indicating access granted:


  • As in the first round, try some other combinations and make sure that they result in the decimal Bank Vault Receiver displaying an X to indicate access denied.