What it shows
A signal sprite changes between stop and walk using wait blocks, and a child sprite checks the signal before moving. It teaches road safety and conditional logic together.
The science
A variable called signal stores the current state as a word. The signal sprite changes the word on a timer, and the child sprite reads it before acting. Programs often share a state like this so that different parts agree. The if else block makes the child follow the rule: cross only on walk.
Materials
Cost: free. Many items come from home or from waste; spare parts such as LEDs, motors and wire are in the store.
- A computer, laptop or phone with a browser (free)
- Scratch 3 in the browser at scratch.mit.edu (free, no sign-in needed to code)
- A road backdrop, a child sprite, and a signal sprite with two costumes named stop and walk
- A notebook and a pencil
Safety
This project uses safe, everyday materials. Still, read the rules below with a parent before you start.
Never use mains electricity: power models with cells, batteries or a low-voltage adapter. Sharp and hot tools, flames and lab chemicals need an adult or your teacher beside you. Keep magnets, button cells and small parts away from young children, and wash your hands after making.
All the safety rulesStep by step
8 steps. Do them in order, and test each part before you go on to the next. Write what you notice in a notebook as you go.
Draw or pick a road backdrop, and place the child at the bottom of the stage and the signal at the side.
Make a variable called signal and another called crossed for all sprites.
On the signal sprite paint two costumes, a red hand named stop and a green walking person named walk.
On the signal sprite: when green flag clicked, forever, set signal to stop, switch costume to stop, wait 4 seconds, set signal to walk, switch costume to walk, wait 4 seconds.
On the child: when green flag clicked, go to x: 0 y: -150 and set crossed to 0.
Add when up arrow key pressed, then if signal = walk then change y by 20, else say Stop! Wait for the walk signal for 1 seconds.
Add a forever loop in another script: if y position > 140 then say I crossed safely! and stop all.
Test by pressing the up arrow at the wrong and right times, and tune the wait times.
What you should see
The child moves up the road only when the signal shows walk. Pressing the key at stop makes the child say Stop and stay put. Reaching the far side shows I crossed safely.
Viva questions
A teacher or a judge will ask how it works. Try to answer each question before you open it, then compare.
1What does the signal variable do?
It stores whether the signal is stop or walk so other sprites can read it.
2Why use if else here?
To move on walk and warn on stop.
3What road-safety rule does the game teach?
Cross only when the pedestrian signal says walk, using the zebra crossing.
4How can you make it harder?
Add moving cars that must be avoided even on walk.
Take it further
Add a car sprite that glides across only while the signal is stop and make the child lose a life if touched.
Change one thing, measure what happens, and add a table or chart of your readings: that is what turns a model into your own investigation.
Free ebooks for this project
Computer & office
Computer Fundamentals Study Book
The complete study notes, practice questions and glossary for Computer Fundamentals
