How the Bank Vault Cracking Works
The project starts by declaring a list named digits with single character strings ‘0’ and ‘1’.
The show arrow (west) call makes the LED display point at the A button as a prompt to press it to start the process. After that, the forever loop repeatedly checks if the A button was pressed, and does nothing else until you press it. After the A button is pressed, the clear screen call erases the arrow so that it can start displaying the 0/1 digits without any leftover LED pixels from the arrow.
These three nested loops cycle through each possible combination in pin. The project starts setting a to ‘0’, then b to ‘0’, and c to ‘0’. Then, set pin to (join (a) (b) (c)) creates the string ‘000’ by combining the three characters. The for c in digits loop isn’t done yet so it sets c to ‘1’. Then, set pin to (join (a) (b) (c)) repeats, and this time, the result is ‘001’.
Now that the for c in digits loop is finished, the for b in digits loop has to do its next iteration, setting b to ‘1’. Since for c in digits is below and indented, it has to repeat that loop again. This time, a is still ‘0’, but b is now ‘1’. So, when c is ‘0’, the result of set pin to (join (a) (b) (c)) is ‘010’. On the for c in digits second repetition, it sets c to ‘1’ and the result of set pin to (join (a) (b) (c)) is ‘011’. It continues this way through all the possible 0/1 combinations.
A lot more happens each time through the for c loop. First, it displays the current pin combination in the terminal.
Then, it displays the PIN as 0/1 digits with the LED display.
It also checks for the radio response from the Vault Receiver micro:bit. This loop sends repeatedly and checks for a response each time. When it does get a response, it exits the while (received ≠ 1)… loop.
Still inside the for c in digits… loop. Once a response has been received, it prints to the terminal. Then, if the response is “Access granted.”, it means the PIN was correct. At that point, the correct PIN scrolls through the PIN Pad Transmitter micro:bit’s display repeatedly.
The response string could also be “Access denied.” In that case, the project resets the received variable, waits 4 seconds, then clears its display and lets for c in digits… loop to repeat with the next pin string in the sequence.