Skip to main content
โ† Back to Traditional Coding samples
โŒจ๏ธTraditional Codingยท15 minยทSample Lesson

Codes Are Everywhere: From Traffic Lights to Video Games

Did you know a traffic light is following code? Red, yellow, green, over and over -- someone wrote instructions for that light to follow, just like someone writes instructions for your favorite video game character to jump when you press a button!

What You'll Learn

- What 'code' means for a computer - Three places codes hide in everyday life - How a set of steps (an algorithm) makes things happen in order - How to write your own simple set of instructions

Code Is Just Instructions

When we say 'code,' we mean a list of instructions that tells a computer or machine exactly what to do, step by step, in order. A microwave has code inside it that says: when the door opens, turn off the light; when the button is pressed, count down the minutes. Code doesn't have feelings or guesses -- it does exactly what it's told, in the exact order it's told.

Spotting Code in the Real World

A vending machine runs on code: insert coin, check the amount, if enough money, drop the snack. A video game runs on code: if the player presses the jump button, make the character go up, then come back down. Even a washing machine runs on code: fill with water, spin, drain, spin again, done. Code is the invisible list of steps behind machines you use every day.

Did You Know?

The first computer 'programmer' was Ada Lovelace, who wrote instructions for a mechanical calculating machine back in the 1840s -- before computers even looked like the ones we use today!

Steps in Order Matter

A list of steps done in order is called an algorithm. If you mix up the order, things go wrong! Imagine an algorithm for brushing your teeth: put toothpaste on the brush, THEN brush, THEN rinse. If you rinse before brushing, the algorithm breaks. Computers are the same way -- the order of instructions changes what happens.

โ“

What is an algorithm?

Match each machine to the code-like instruction it might follow.

Terms

Traffic light
Vending machine
Washing machine
Video game character

Definitions

Turn red, then yellow, then green, repeat
Fill with water, spin, drain, spin again
If jump button pressed, move up then come back down
If enough coins are inserted, release the snack

Drag terms onto their definitions, or click a term then click a definition to match.

โ“

Why does the ORDER of steps matter in an algorithm?

๐ŸŽฏ

Write Your Own Machine Algorithm

Pick a machine you use at home (a toaster, a remote control, a doorbell). Write out, in order, 4-6 numbered steps that describe exactly what it does from start to finish. Then swap your list with a family member and see if they can guess which machine you described just from your steps.

Try This

Next time you see a traffic light, count how many seconds each color stays on. That timing is part of its code too!

Want to keep learning?

Sign up for free to access the full curriculum โ€” all subjects, all ages.

Start Learning Free