Year 9 · Summer 1
Physical Computing · Lesson 1 of 5
Lights and the first program
PracticalTopic 1 What a computer is
Year 9 · Physical Computing · Lesson 1 of 5
You will learn to
- Explain current, voltage and resistance, and why current needs a complete loop.
- Build a circuit in Tinkercad where a button turns an LED on.
- Calculate the resistor an LED needs with Ohm's law.
- Write Blink in blocks and in C++, and explain setup(), loop(), digitalWrite and delay.
Year 9 · Physical Computing · Lesson 1 of 5
Success criteria
You have got it when you can say:
- I can build the button circuit with the LED the right way round.
- I can work out (5 − 2) ÷ 0.02 = 150 Ω, and say why 220 Ω is also safe.
- I can change Blink so the LED flashes twice as fast.
Year 9 · Physical Computing · Lesson 1 of 5
Retrieval starter
Questions from before. Write your answers, then show them.
- Last unit
Turning a microphone's voltage into numbers is done by…
A An ADCB A DAC
A. An ADC
- Last unit
Which is metadata?
A The image's widthB The colour of pixel 7C A pixel's red value
A. The image's width
- Earlier this year
A variable made inside a function is…
A Local: only exists inside it while it runsB Global: usable anywhereC Saved to a file
A. Local: only exists inside it while it runs
Year 9 · Physical Computing · Lesson 1 of 5
Key words (1 of 2)
- Input / output
- Anything that gets information into the computer. Keyboard, mouse, touchscreen, microphone, camera, a temperature sensor.
- Process
- The computer follows instructions to change that information. Add two numbers. Move a character. Sort a list. The CPU does this.
- Transistor
- An electronic switch with no moving parts.
- Hardware
- The physical parts of a computer.
Year 9 · Physical Computing · Lesson 1 of 5
Key words (2 of 2)
- Software
- Programs: instructions that tell hardware what to do.
- Embedded system
- A small computer built into a device for one job.
The explanation · step 1 of 4 · part 1 of 2
Electricity flows in a loop
Electricity only flows round a complete loop, called a circuit. Break the loop anywhere and it stops.
| Word | What it means | Unit |
|---|---|---|
| Voltage (V) | The push that drives electricity round the circuit | volts (V) |
| Current (I) | How much electricity flows past a point each second | amps (A). 1000 milliamps (mA) = 1 A. |
| Resistance (R) | How hard it is for current to flow | ohms (Ω) |
On an Arduino, 5V is the + side. GND (ground) is the − side, at 0 volts.
The explanation · step 1 of 4 · part 2 of 2
Electricity flows in a loop (continued)
Current flows from +, round the loop, back to −. Every part must sit in that loop.
The explanation · step 2 of 4 · part 1 of 2
The parts
- Arduino Uno: a small board with a microcontroller, a tiny computer on one chip. Wires join it at its numbered pins.
- Breadboard: a board for building circuits without solder. The long + and − rails carry power along its edges.
- LED (light-emitting diode): a small light that lets current through one way only.
- Resistor: limits the current. It works either way round.
- Pushbutton: a switch. Pressed, it closes the loop. Let go, it breaks the loop.
The explanation · step 2 of 4 · part 2 of 2
The parts (continued)
An LED's anode (+) must face the + side. Its cathode (−) faces the − side.
On a real LED the anode is the longer leg. In Tinkercad it is the bent leg.
The 5 holes in one short column of the breadboard are joined inside. If a part has both legs in one column, the current skips it.
The explanation · step 3 of 4 · part 1 of 3
Why an LED needs a resistor
With no resistor, too much current flows. The LED burns out, and the Arduino pin can be damaged.
Ohm's law links the three words: V = I × R. Turned round, it tells you the resistor you need.
| Symbol | Means | For a red LED |
|---|---|---|
| Vs | The supply voltage | 5 V |
| Vf | The voltage the LED uses up | about 2 V |
| I | The current you want, in amps | 20 mA = 0.02 A |
| R | The resistor you need: R = (Vs − Vf) ÷ I | ? |
The explanation · step 3 of 4 · part 2 of 3
Why an LED needs a resistor (continued)
- Take the LED's share away from the supply: 5 − 2 = 3 V.
- Divide by the current: 3 ÷ 0.02 = 150 Ω.
- Use 150 Ω, or the next size up. Kits use 220 Ω.
Why is 220 Ω also safe?
A bigger resistor lets less current through: 3 ÷ 220 ≈ 0.014 A, or 14 mA. The LED is a little dimmer, and safer.
The explanation · step 3 of 4 · part 3 of 3
Why an LED needs a resistor (continued)
Keep the current from each Arduino pin at about 20 mA or less.
The explanation · step 4 of 4 · part 1 of 4
Blink: the first program
Wire pin 13 to the resistor instead of the button. Now the Arduino flips the switch.
The explanation · step 4 of 4 · part 2 of 4
Blink: the first program (continued)
const int LED_PIN = 13; // the LED is wired to pin 13
void setup() {
pinMode(LED_PIN, OUTPUT); // pin 13 will send electricity out
}
void loop() {
digitalWrite(LED_PIN, HIGH); // switch ON: 5 volts, a 1
delay(500); // wait 500 milliseconds
digitalWrite(LED_PIN, LOW); // switch OFF: 0 volts, a 0
delay(500); // wait again, then loop() starts over
}The explanation · step 4 of 4 · part 3 of 4
Blink: the first program (continued)
setup()runs once, when the board switches on.pinModemakes pin 13 an output.loop()runs again and again, for ever.digitalWrite(LED_PIN, HIGH)puts 5 V on the pin. That is a 1, so the LED lights.delay(500)waits 500 milliseconds: half a second.LOWputs 0 V on the pin. That is a 0, so the LED goes off.
With a micro:bit, the same idea in MicroPython uses the screen of lights:
The explanation · step 4 of 4 · part 4 of 4
Blink: the first program (continued)
from microbit import *
while True:
display.show(Image.HEART)
sleep(500)
display.clear()
sleep(500)Year 9 · Physical Computing · Lesson 1 of 5
Worked example
A blue LED uses about 3 V. You want 20 mA through it from the Arduino's 5 V. Which resistor do you need?
- Write what you know: Vs = 5 V, Vf = 3 V, I = 20 mA.
- Change the current to amps: 20 ÷ 1000 = 0.02 A.
- Take the LED's share away: 5 − 3 = 2 V.
- Divide by the current: 2 ÷ 0.02 = 100 Ω.
- 100 Ω is a standard size, so use it.
- A 220 Ω resistor also works: 2 ÷ 220 ≈ 0.009 A, or 9 mA. The LED is just dimmer.
Year 9 · Physical Computing · Lesson 1 of 5
The maths: Which resistor does an LED need?
Symbols first, then the words, then the equation. Change the numbers.
Year 9 · Physical Computing · Lesson 1 of 5
Quick quiz · 1 of 3
A microphone hearing your voice is…
- A Input
- B Process
- C Output
A. Input
Information is coming in to the computer.
Year 9 · Physical Computing · Lesson 1 of 5
Quick quiz · 2 of 3
Why do computers use 2 states instead of 10?
- A Two is the biggest number
- B Ten states would be too cheap
- C On and off are easy to tell apart reliably
C. On and off are easy to tell apart reliably
Wobbly signals make 10 levels easy to misread. On/off is reliable.
Year 9 · Physical Computing · Lesson 1 of 5
Quick quiz · 3 of 3
A game you download is…
- A Software
- B Hardware
A. Software
You can't touch it. It's instructions stored as 0s and 1s.
Year 9 · Physical Computing · Lesson 1 of 5
Exit ticket
Answer on paper before you go. Then check.
What controls whether current flows through a transistor?
A A tiny moving armB The voltage on its gateC How hot it is
B. The voltage on its gate The gate is like a tap handle. Voltage on the gate opens the channel.
Two transistors in a line (series) light a lamp only when…
A Neither gate is onB Either gate is onC Both gates are on
C. Both gates are on Current must pass through both, so both must be open. That is AND.