If you are doing these activities by yourself, or want to make it to where you won’t have any knowledge of the PIN you are trying to crack, then modify the bank_vault_receiver script to create a random pin.
# bank_vault_receiver_random_pin # <- change from microbit import * import radio import random # <- add radio.on() radio.config(channel=7) sleep(1000) # pin = '011' # <- comment pin = '' # <- add for n in range(3): # <- add number = str(random.randint(0,1)) # <- add pin += number # <- add print("Random pin =", pin) # <- add while True: display.set_pixel(2,2,9) message = radio.receive() if message: if message == pin: radio.send("Access granted.") for n in range(4): display.show(Image.YES) sleep(1000) display.clear() sleep(200) else: radio.send("Access denied.") display.show(Image.NO) sleep(3000) display.clear()
Each time you reset the Bank Vault micro:bit, it should display a new random PIN in the terminal. (Don’t worry if your random sequence is different from what’s shown here. Yours only has a 1 in 8 chance of matching for any given reset.)
In the place of a previously decided PIN, there is now an empty string and a for loop that repeats three times—randomly choosing a 0 or 1- and then appending the pin string with that digit.
# pin = '011' # <- comment pin = '' # <- add for n in range(3): # <- add number = str(random.randint(0,1)) # <- add pin += number # <- add print("Random pin =", pin) # <- add