Use your browser's Print → Save as PDF to download this document. Back to the unit

Crack the Code

Unit of work Stage 4 10 weeks CC-BY-4.0 · Little Bird Electronics

A NSW Technology Mandatory 7–8 unit of work: students design, produce and evaluate an Arduino-based alarm/alert system. Four hands-on Plug-Run-Play activities — Blink, Button, Analog input and Buzzer — build the coding skills (sequence, branching, variables, the Serial Monitor) the design project needs. Built around the Crack the Code Arduino kit with the MAAS ThinkerShield.

Syllabus outcomes

CodeOutcomeSyllabus
TE4-10TSExplains how people in technology-related professions contribute to society now and into the future.NSW Technology Mandatory 7-8 (2017)
TE4-1DPDesigns, communicates and evaluates innovative ideas and creative solutions to authentic problems or opportunities.NSW Technology Mandatory 7-8 (2017)
TE4-2DPPlans and manages the production of designed solutions.NSW Technology Mandatory 7-8 (2017)
TE4-4DPDesigns algorithms for digital solutions and implements them in a general-purpose programming language.NSW Technology Mandatory 7-8 (2017)
TE4-7DIExplains how data is represented in digital systems and transmitted in networks.NSW Technology Mandatory 7-8 (2017)
TE4-DES-01Designs algorithms for digital and engineered solutions, and represents them with diagrams and pseudocode.NSW Technology 7-8 (2023)
TE4-DES-02Designs solutions to identified needs and opportunities by applying a design process and selecting appropriate tools, materials and processes.NSW Technology 7-8 (2023)
TE4-DIG-01Explains how digital systems represent and transmit data, and how hardware and software components function to meet identified needs.NSW Technology 7-8 (2023)
TE4-DIG-02Uses data and digital systems to code, design and produce projects that respond to inputs through a sequence of instructions.NSW Technology 7-8 (2023)
TE4-ENG-01Explains how engineered systems use components and processes to convert energy, transmit motion and respond to control signals.NSW Technology 7-8 (2023)
TE4-PRO-01Plans, manages and produces a designed solution within identified constraints and to specified criteria.NSW Technology 7-8 (2023)
TE4-PRO-02Selects and safely uses appropriate tools, materials and processes to produce designed solutions.NSW Technology 7-8 (2023)
TE4-SOC-01Explains how people in technology-related professions contribute to society and the impact of their work on individuals, communities and the environment.NSW Technology 7-8 (2023)

Teacher overview

About this unit

Crack the Code is a Stage 4 Technology Mandatory unit in which students individually design, produce and evaluate an alarm/alert system using a microcontroller. Across roughly ten weeks they learn programming concepts and commands — sequence, branching (if/else), variables (int), analog input and the Serial Monitor — and how to modify code to suit an identified need, then apply those skills to a design project. The unit also introduces basic electronics so the final design runs on a built circuit rather than only on the ThinkerShield.

Design situation. As an adolescent in the 21st century you are surrounded by technology. Even simple electronic devices — a TV remote, Tickle Me Elmo — use a computer program (their code) to tell them what to do. What if you could control what an electronic device does? In this unit you will.

How the ten weeks run

Weeks Phase Focus
1–2 Identifying & defining Design process, the brief & constraints, control technologies, microcontrollers, the Arduino/ThinkerShield, safety
1–2 Researching & planning Loading the Blink sketch, the Arduino IDE, pseudocode, PRP #01 Blink, if statements & the int command, binary numbers
3–4 Researching & planning Inputs (sensors), PRP #02 Button, PRP #03 Analog input + Serial Monitor, outputs (actuators), PRP #04 Buzzer, extension work
5–7 Researching & planning KWL chart, project IPO chart, brainstorm, four design ideas + PMI, time/action & finance plans, testing & selecting two ideas
8–9 Producing & implementing Final design as a working, tactile project; circuit components; basic electronics; tools & safety; circuit assembly
10 Testing & evaluating Final evaluation using Bloom's taxonomy against the brief and criteria for success

Plug-Run-Play (PRP) activities

Four short hands-on activities build the coding skills the design project needs. Each one: upload (or type) a sample sketch, run it, complete an IPO chart, compare your pseudocode to the real code, then modify the sketch to meet a series of challenges and reflect. The sample sketches are hosted here as code snippets and are wired for the MAAS ThinkerShield (LED on D12, button on D7, buzzer on D3, potentiometer on A5, LDR on A4) so they run straight away.

  1. PRP #01 — Digital output: BlinkpinMode, void setup/void loop, digitalWrite, delay.
  2. PRP #02 — Digital input: ButtondigitalRead, if/else, comparison operators, the int command for naming pins.
  3. PRP #03 — Analog input: potentiometer & LDRanalogRead (0–1023), the Serial Monitor (Serial.begin, Serial.print, Serial.println), thresholds.
  4. PRP #04 — Digital output: Buzzer — the tone(pin, frequency, duration) command, building an alternating-tone alarm, button-controlled and toggled buzzers. Two model "alarm" sketches are included as a starting point for the design project.

Assessment — marking criteria (each focus area /20)

Bands: Outstanding 18–20 · High 15–17 · Sound 11–14 · Basic 6–10 · Limited 0–5.

Focus area Outstanding (18–20)
Project management Time/action and finance planning is extensive; the project is completed within the time and budget; flowcharts follow a clearly logical sequence that solves the brief.
Coding and function Coding is error-free and works in the design project; there is evidence of error-checking and tinkering; the project functions as intended to fulfil the brief.
Physical electronics The project is housed in an aesthetically pleasing, appropriate enclosure; the circuit appears fault-free and is well constructed.
Final evaluation The evaluation is detailed, objective and descriptive — outlining areas of success and areas for improvement (and why) if the project were made again.

Resources & equipment

Attribution

Adapted from the NSW Department of Education Crack the Code materials (V3.x, 2018) — developed by Danielle Saunders (Elderslie HS), Alexander Stewart & John Wallace (Carlingford HS) and Dan Rytmeister (Learning & Teaching Directorate), with the Museum of Applied Arts & Sciences (MAAS) and others. The DoE publishes these for TAS teachers under CC-BY 4.0. Syllabus outcomes are from the Technology Mandatory Years 7–8 Syllabus © NSW Education Standards Authority (NESA), 2017.

Design brief

Utilising your skills in control technologies and coding, you are to design, produce and evaluate an alarm/alert system to inform you if someone has broken into something you own or care for — for example a bedroom, a box or a treasure chest.

Constraints

Your ability to develop, assemble and code a control technology is bounded by your budget, ability and time frame. Your control technology must:

Criteria for success

The class refines the evaluation criteria to five key points. The finished project:

  1. is a control system (input → processing → output);
  2. is an alert/alarm system with a stated end-use application;
  3. uses a microcontroller (Arduino + ThinkerShield while prototyping, then a built circuit);
  4. includes working inputs (one or more sensors);
  5. includes working outputs (one or more actuators) that change with the input.

Teaching program

1. Understanding control technologies (Identifying & defining)

Teacher

Students

Resources

Crack the Code teacher information booklet & student workbook; a functioning example of the project; a TV remote control; Tickle Me Elmo YouTube clip (muted); a class set of Arduino Uno boards + USB cables + MAAS ThinkerShields; a computer room with the Arduino software.

Outcomes: TE4-1DP, TE4-2DP, TE4-7DI, TE4-10TS, TE4-DIG-01, TE4-SOC-01

2. First code — Blink, the IDE & binary (Researching & planning)

Teacher

Students

Resources

Crack the Code teacher information booklet & student workbook; the Control Technologies PowerPoint and teacher notes; data projector & computer; a class set of Arduino Uno boards + cables + ThinkerShields; a computer room with the Arduino software; Technology Mandatory Years 7–8 Syllabus 2017 p.61. Sample sketch: _01_Blink.ino.

Outcomes: TE4-4DP, TE4-7DI, TE4-DES-01, TE4-DIG-02

PRP 1: Digital output — Blink

Upload the _01_Blink.ino sketch and watch the D12 LED flash on for a second, off for a second, forever. Then go deeper into the sketch:

  1. Pseudocode it. In plain English, how would you make the classroom lights blink on and off every ten seconds? (Turn the switch on → wait → turn it off → wait → repeat.) Now write the pseudocode for the Blink sketch itself.
  2. Make connections. Re-open _01_Blink.ino and compare your pseudocode to the real code — same order? Similar steps? Different language?
  3. Understand the code. Work out what each line means: pinMode(12, OUTPUT) makes pin 12 send current out (to the LED); void loop() { starts the forever-loop; digitalWrite(12, HIGH) turns pin 12 on; delay(1000) waits 1000 milliseconds (1 second); digitalWrite(12, LOW) turns it off.
  4. Label the IDE. Use the word bank to label the sketch title, status bar, upload & verify buttons, Serial Monitor, comments, curly braces, the semicolon, void setup, the debug area.
  5. Flowchart it. Draw the flowchart for Blink (terminator → process → delay → …).
  6. Challenges. Then modify the sketch:
    • change how long the LED is on for;
    • change how long the LED is off for;
    • make two LEDs flash on and off together (e.g. D12 and D8);
    • make the LEDs "chase" each other from D12 down to D9;
    • make the LEDs come on in pairs or your own pattern.

Get a partner or your teacher to tick off each challenge, then complete the self-reflection.

InputsProcessingOutputs
None — Blink runs on a fixed timer (there is no sensor)void setup() runs once: set pin 12 as an OUTPUT with pinMode(12, OUTPUT), void loop() repeats forever: digitalWrite(12, HIGH) → delay(1000) → digitalWrite(12, LOW) → delay(1000)LED on the ThinkerShield, pin D12

Code: _01_Blink.ino (https://littlebirdelectronics.com.au/code/w3AhJuQBWiM)

Extension:

Troubleshooting:

3. Inputs, outputs & the PRP activities (Researching & planning)

Teacher

Students

Resources

Crack the Code teacher information booklet & student workbook; the Control Technologies PowerPoint; data projector & computer; a class set of Arduino Uno boards + cables + ThinkerShields; optional VEA video (vea.com.au). Sample sketches: _02_Button.ino, _03_int.ino, _05_analog_input.ino, _07_Buzzer1.ino, _08_Buzzer2.ino, _09_Buzzer3.ino.

Outcomes: TE4-4DP, TE4-7DI, TE4-DES-01, TE4-DIG-02

PRP 2: Digital input — Button

Load _02_Button.ino — this sketch uses the ThinkerShield button (pin 7) to control the D12 LED. Press the button: the LED comes on. Let go: it goes off. The button is a digital input — it's only ever on or off (a binary input).

New ideas in this PRP:

Then: write pseudocode for "turn the LED on when the button is pressed, off when released"; draw the flowchart; answer the "making connections" questions; and tackle the challenges:

Get a partner or your teacher to tick off each challenge, then complete the evaluation questions.

InputsProcessingOutputs
Pushbutton on the ThinkerShield, pin D7 (digital — reads HIGH or LOW)void setup() sets the LED pin as OUTPUT and the button pin as INPUT, void loop() reads the button: buttonState = digitalRead(buttonPin), if buttonState == HIGH → turn the LED on; else → turn the LED offLED on the ThinkerShield, pin D12

Code: _02_Button.ino (https://littlebirdelectronics.com.au/code/Ffji7vnK1uw) · _03_int.ino (https://littlebirdelectronics.com.au/code/5btMKror5pg)

Extension:

Troubleshooting:

PRP 3: Analog input — potentiometer & LDR

Load _05_analog_input.ino — this sketch lets a potentiometer (the knob marked POT A5 on the ThinkerShield) or a light-dependent resistor (LDR) control the LED. Unlike a button (only 0 or 5 V), an analog input can be anything in between: analogRead() turns the 0–5 V range into a number from 0 to 1023. Turn the knob and the blink rate changes.

The Serial Monitor. Your code might not look like it's working — the Serial Monitor shows you what's happening "in the background". Add Serial.begin(9600); in setup() (the 9600 is the speed — it must match the dropdown at the bottom of the Serial Monitor window), then Serial.print("text") writes text on the same line and Serial.println(value) writes a value and starts a new line.

Then: write pseudocode to make the LED blink faster/slower as you turn the pot; answer the "making connections" questions; and tackle the challenges:

Get a partner or your teacher to tick off each challenge, then complete the evaluation questions.

InputsProcessingOutputs
Potentiometer on the ThinkerShield, pin A5 (analog — a value from 0 to 1023), Light-dependent resistor (LDR) on pin A4 (analog) — for the night-light challengesensorValue = analogRead(sensorPin) — read the knob (or the light level), Use sensorValue as the delay so the blink rate tracks the knob — or compare it to a threshold (e.g. < 300) to switch the LED, Serial.print / Serial.println report the value to the Serial MonitorLED on the ThinkerShield, pin D12, Text on the Serial Monitor

Code: _05_analog_input.ino (https://littlebirdelectronics.com.au/code/3cZ8etQDBns)

Extension:

Troubleshooting:

PRP 4: Digital output — Buzzer

Type up (or load) _07_Buzzer1.ino — it makes the piezo buzzer (pin 3) beep using the tone(pin, frequency, duration) command: tone(buzzerPin, 600, 30); plays a 600 Hz tone for 30 ms, then delay(150); waits 150 ms before the loop repeats. A piezo buzzer isn't a speaker, but it still outputs sound.

Then: write pseudocode to make the buzzer sound; answer the "making connections" questions; make it sound like an alarm by alternating a low and a high tone (see _08_Buzzer2.ino); and tackle the challenges:

Get a partner or your teacher to tick off each challenge, then complete the evaluation questions. _09_Buzzer3.ino is an extension: it uses a for loop to sweep the tone smoothly up and back down.

InputsProcessingOutputs
None for the basic sketch — it is timer-driven, Pushbutton on pin D7 — for the button-controlled and toggled-buzzer challengesvoid setup() sets the buzzer pin (3) as an OUTPUT, void loop(): tone(buzzerPin, frequency, duration) then delay(...) — repeat, Alarm version: alternate a low tone and a high tone with a delay between eachPiezo buzzer on the ThinkerShield, pin D3

Code: _07_Buzzer1.ino (https://littlebirdelectronics.com.au/code/zF5ehU-ICnk) · _08_Buzzer2.ino (https://littlebirdelectronics.com.au/code/oq8Blb4lOt0) · _09_Buzzer3.ino (https://littlebirdelectronics.com.au/code/XQZWZDEVHi0) · _10_Alarm_Basic.ino (https://littlebirdelectronics.com.au/code/uvSkLjeldRA)

Extension:

Troubleshooting:

4. Generating, developing & testing design ideas (Researching & planning)

Teacher

Students

Resources

Crack the Code teacher information booklet & student workbook; a class set of Arduino Uno boards + cables + ThinkerShields. Model sketches to adapt: _10_Alarm_Basic.ino (a simple armed-then-triggered box alarm) and _08_Buzzer2.ino (an alternating-tone alarm sounder).

Outcomes: TE4-1DP, TE4-2DP, TE4-4DP, TE4-DES-02, TE4-PRO-01

5. Final design, circuits & electronics (Producing & implementing)

Teacher

Students

Resources

Crack the Code teacher information booklet & student workbook; a class set of Arduino Uno boards + cables + ThinkerShields; the Crack the Code ready reckoner; electronic components (LEDs, 220 Ω resistors, jumper leads, breadboards, push buttons, piezo buzzers, LDRs, copper tape, battery holders); long-nose pliers; a circuit-illustration tool (e.g. Fritzing).

Outcomes: TE4-1DP, TE4-2DP, TE4-4DP, TE4-PRO-01, TE4-PRO-02, TE4-ENG-01

6. Final evaluation (Testing & evaluating)

Teacher

Students

Resources

Crack the Code teacher information booklet & student workbook.

Outcomes: TE4-1DP, TE4-2DP, TE4-DES-02, TE4-PRO-01

Glossary

actuatorA component that performs a task or action when given a command — for example a servo motor in a remote-control car that turns the steering.
analogReadA command that converts an input voltage in the 0–5 V range to a number between 0 and 1023, using an analog-to-digital converter (ADC) inside the microcontroller.
analogue inputAn input voltage on Arduino anywhere between 0 and 5 volts (as opposed to digital, which is only off or on — 0 or 5).
analogue outputAn output voltage on Arduino anywhere between 0 and 5 volts (as opposed to digital, which is only off or on).
analogWriteWrites an analog value to a pin — used to light an LED at varying brightness or drive a motor at various speeds. The value ranges from 0 to 255.
anodeThe positive leg of an LED. An LED only conducts (and lights) when current flows from the anode to the cathode.
ArduinoA small, easy-to-use programmable microcontroller board (and the company that makes the boards and the software to program them).
binaryA base-2 counting system using only 0 and 1. All data in a computer is stored in binary because the hardware is electronic — on (1) or off (0).
bitA single binary digit — a 1 or a 0.
boardA surface that electronic components are attached to. It must not conduct electricity.
branchingAn instruction that causes different actions depending on specified conditions. Flowcharts show branching with diamond decision symbols.
byteA block of eight bits. A byte represents a number from 0 to 255 (256 values, but counting starts at 0).
camel caseJoining words together and capitalising the start of each word after the first — e.g. `pinMode`, `digitalWrite`, ThinkerShield. Commands are case-sensitive.
cathodeThe negative leg of an LED. If an LED is in the wrong way round, swap the connections.
codingAnother word for computer programming — writing the instructions (the *code*) that tell a computer or microcontroller what to do.
commentsNotes added next to lines of code to explain them. In Arduino, comments start with `//`; the compiler ignores everything after the `//` on that line.
compileTranslating a sketch into the machine language the microcontroller runs. The Arduino IDE compiles a sketch (and checks it for syntax errors) before uploading it.
componentAn electronic part that on its own generally has no function, but which can perform a task when combined with others into a circuit.
conductiveAble to carry electric current — e.g. copper wire. Don't rest a board on a conductive surface.
constShort for *constant* — a value the programmer does not want changed, e.g. `const int ALARMSOUNDER = 3;`.
control technologyAn electronic device that uses inputs to create outputs — for example traffic lights, a dishwasher, or a TV remote control.
declarationDefining the type of a variable (and optionally its initial value). In an Arduino sketch the declarations sit before `void setup()`.
digital inputAn input that is only on or off — it can't gradually turn on or off.
digital outputAn output that can only be switched on or off (HIGH or LOW), not set to a percentage — though PWM pins can fake a percentage by switching very fast.
digitalReadReads a HIGH or LOW signal from a pin that has been set as an input.
digitalWriteSends a HIGH or LOW signal to a pin that has been set as an output.
electrical circuitA path that allows electricity to flow. A circuit must be *closed* (no breaks) for current to flow all the way around.
falseNot true — no electrical current present. Also called OFF, LOW or 0.
for loopA loop that runs a fixed number of times and then stops — e.g. `for (i = 0; i < 10; i++) { … }`. Unlike `void loop()`, it doesn't run forever.
functionA named block of code that does a particular job — e.g. `setup()` and `loop()`, or built-ins like `digitalWrite()` and `tone()`.
hardwareThe physical parts of the system — the electrical circuit, components and the microcontroller (Arduino).
HIGHON / true / 1 — electrical current present (up to 5 V on an Arduino Uno).
IDE (Integrated Development Environment)The software you write, check and upload a sketch in — for Arduino, the Arduino IDE. Different IDEs use different programming languages.
if statementA conditional that lets the program decide what to do based on a condition — e.g. turn an LED on *if* a button is pressed. Often paired with `else`.
Input, Processing and Output (IPO) chartA simple map of the input and output components of a control system, making it easier to understand and design.
integer (int)A whole number. The `int` command declares an integer variable — often used to give a pin an intuitive name, e.g. `int ledPin = 12;`.
light dependent resistor (LDR)A component whose resistance changes with the amount of light falling on it — used to detect light or dark.
light emitting diode (LED)A component that emits light and only lets current pass one way (anode → cathode). Available in many colours; usually wired with a series resistor.
LOWOFF / false / 0 — no electrical current present.
microcontrollerA small programmable computer that can run code. Once programmed it doesn't need a computer attached. Also called a programmable logic controller (PLC).
multimeterA tool that measures a range of electrical values — current (amps), continuity, resistance and voltage — on circuits and components.
piezo buzzerMakes a buzzing sound when current is applied. It isn't a speaker, but it still outputs sound — driven by the `tone()` command.
portA connection point on the Arduino (or ThinkerShield) where a sensor or actuator plugs in. (Also: the COM/serial port the board appears on when plugged into a computer.)
potentiometerA resistor whose resistance changes when you turn a knob or move a slider — like the volume control on a radio. Marked POT A5 on the ThinkerShield.
power supplySupplies the circuit with power — from small batteries (like in a watch) to mains power packs. Lets a microcontroller run independently of a computer.
pseudocodeWriting, in plain English, line by line, what you want a program to do — explicit, step-by-step instructions in a logical sequence.
pulse width modulation (PWM)Dimming an output (like an LED) by switching it on and off very fast. Available on Arduino pins marked `~` (3, 5, 6, 9, 10, 11); controlled with a value 0–255.
resistorA component that reduces (resists) the current in a circuit. An LED is usually wired with a 220 Ω resistor in series so it doesn't burn out.
sensorA device connected to the microcontroller that detects a change in its environment and provides that data to the microcontroller — e.g. a button, an LDR, a motion sensor.
serial monitorA window in the Arduino IDE that shows data the sketch prints with `Serial.print` / `Serial.println` — useful for checking what a program is doing.
shieldA board that fits onto the microcontroller via its analog and digital pins, adding an easy-to-use interface or built-in components. The MAAS ThinkerShield is an example.
sketchArduino's name for a program — the code you write in the Arduino IDE and upload to the board.
syntaxThe spelling and grammar of code. It must be exactly right or the computer won't know what to do. Commands are case-sensitive.
tactile switchA switch operated by a person — e.g. a pushbutton.
ThinkerShieldAn Arduino shield developed by the Museum of Applied Arts & Sciences (MAAS, Sydney) with on-board LEDs, a button, a potentiometer, an LDR and a buzzer — so you can learn to code without first learning electronics.
toneAn Arduino command, `tone(pin, frequency, duration)`, that drives a piezo buzzer at a given frequency (Hz) for a given time (ms).
trueON / HIGH / 1 — electrical current present (up to 5 V on an Arduino Uno).
variableA named storage location for a value that can change while the program runs (e.g. `buttonState`). Declared with a type, such as `int`.
void loopThe section of an Arduino sketch that runs after `void setup` and then repeats forever (until the power is removed or new code is uploaded).
void setupThe section of an Arduino sketch that runs once at the start, used to prepare the board (e.g. set pin modes). The sketch won't run correctly without it.
volts (voltage)The unit of electrical 'pressure' — how hard the current wants to flow. An Arduino Uno works at up to 5 V.

Bill of materials

RoleProductSKUQty / studentQty / class of 30Price
CoreSingle Crack the Code Arduino with Crack the Code Shield and CaseLB-CTCSINGLE130$50.60
CoreCrack the Code ShieldLB-CTCTHINK121$21.50
Shared classroomCrack the Code Arduino with Crack the Code Shield and CaseLB-CTCYELLOW02$956.49

Add the core kit to your cart at https://littlebirdelectronics.com.au/curriculum/crack-the-code