
About this lesson
Welcome to our micro:bit-based teacher resource for generating random 4-digit PINs, ideal for educators experienced in tech or beginners. Micro:bits facilitate coding and computational thinking, allowing you to teach cybersecurity through hands-on PIN generator projects, fostering coding skills and security awareness.
Activity
1.
Create four variables named digit_1, digit_2, digit_3 and digit_4 . These will be used to represent the four digits of the pin code

2.
Use on button A pressed to set the digit_1 to a random number between 0 and 9 and then show what value the variable has been given.

3.
Repeat with the other variables

4.
If you press A again, it will generate a new password. To see the first pin again, we need to write another piece of code for on button B pressed.

5.
If a number repeats, it can be hard to tell that it is another digit. To help with that, put clear screen and pause (ms) 100 in between show number <variable>

6.
See completed code here.
Discussion
- What makes a good pin code?
- Are there any other ways to create a 4 digit pin?
- Are they all as secure as each other?
- How could we make a password more secure?
Extension Activities

Advanced Password Generator
Use arrays to create an Advanced Password Generator to create an 8 digit password with letters, numbers and special characters.
Passphrase Generator
Get even more secure with a passphrase generator that creates unique, random passphrases from a selection of words.


Micro:bit Mastermind Game
Create a code-breaker mastermind game on the Micro:bit
Curriculum Links
Australian Curriculum V 9.0
Digital Technologies
Years 3 & 4
Digital systems
explore and describe a range of digital systems and their peripherals for a variety of purposes
Data representation
recognise different types of data and explore how the same data can be represented differently depending on the purpose
Generating and designing
follow and describe algorithms involving sequencing, comparison operators (branching) and iteration
generate, communicate and compare designs
Producing and implementing
implement simple algorithms as visual programs involving control structures and input
Evaluating
discuss how existing and student solutions satisfy the design criteria and user stories
Collaborating and managing
use the core features of common digital tools to create, locate and communicate content, following agreed conventions
Privacy and security
access their school account using a memorised password and explain why it should be easy to remember, but hard for others to guess
Years 5 & 6
Data representation
explain how digital systems represent all data using numbers
Producing and implementing
implement algorithms as visual programs involving control structures, variables and input
Privacy and security
access multiple personal accounts using unique passphrases and explain the risks of password re-use

