An Arduino Uno names its pins by number, and the code must use the number of the pin the wire goes to. pinMode sets a pin as an output; digitalWrite switches it HIGH or LOW. The circuit ideas from the micro:bit carry straight over.
Most electronics kits, sensors and project guides assume an Arduino. The circuits are the ones you already know. What changes is the board, and then the language.
This is an Arduino Uno. Like the micro:bit it has pins, but they are named by number (0 to 13, plus A0 to A5), and it is programmed in C++. The board on this page runs the sketches for you; in Tinkercad Circuits you can build the same thing with blocks and see the C++ beside them.
void setup() {
pinMode(13, OUTPUT); // pin 13 is an output
}
void loop() {
digitalWrite(13, HIGH); // pin 13 on (5 V)
delay(500); // wait half a second
digitalWrite(13, LOW); // pin 13 off (0 V)
delay(500);
}
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Practise: A few on your own, to check you have it.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
WidthMore contexts, same idea.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Which pin?
TryTry it on the board and compare the result with your prediction.
Try: run it
Try it yourselfYour edits are saved in this browser.
Upload and run the sketch. What does the LED on pin 12 do?
Use the board. This ticks when you get there.
InvestigateWork out why it happens, one step at a time.
Worked example: read the pins
Worked exampleBefore each step, say what you think comes next.
pinMode(13, OUTPUT)Sets pin 13 up as an output. Pin 13, not the LED's pin 12.
digitalWrite(13, HIGH)Switches pin 13 to 5 V. Nothing is wired there.
digitalWrite(13, LOW)Switches pin 13 back to 0 V.
LED on pin 12Pin 12 is never set up or switched, so the LED stays dark.
fix: 12 in every lineOr move the wire to pin 13. Code and wiring must agree.
Now find every line to change.
Sam's LED is on pin 13. It doesn't blink: it just glows very dimly now and then. Click the line where Sam's sketch goes wrong.
ModifyChange the problem on purpose and see what happens.
Vary: change the pin
Try it yourselfYour edits are saved in this browser.
Change the sketch so the LED on pin 12 blinks. Upload and run it.
Use the board. This ticks when you get there.
Modify TypicalChange the problem on purpose and see what happens.
Build it in Tinkercad
PractiseA few on your own, to check you have it.
Pins
MakeMake your own problem using what you have learned. Expect a few tries; that is normal.
Your own sketch
Try it yourselfYour edits are saved in this browser.
Need a hint?
setup() runs first: set the pin up there.
Another hint
pinMode(7, OUTPUT); in setup(), digitalWrite(7, HIGH); in loop().
Another hint
Every line ends with ;
The LED is wired to pin 7. Write the sketch to switch it on (and keep it on).
Use the board. This ticks when you get there.
For teachers
Students run a blink sketch whose pin number doesn't match the wiring, fix every pin number, see the dim pull-up glow of a missing pinMode, build the circuit on an Uno in Tinkercad blocks and read the C++ beside them, then write a short sketch for a new pin. About 40 minutes.
I can match the pin numbers in a sketch to the wiring.
I can set a pin as an output and switch it on and off.
I can find the C++ behind Tinkercad's blocks.
Before class
The board in the lesson runs a subset of Arduino C++ against a model of an Uno (5 V pins, an LED and resistor per pin, simulated time). It behaves like the real board for the things these lessons teach: a missing ; stops the upload, a pin written HIGH without pinMode glows dimly (the internal pull-up), = in an if assigns. It is not a full compiler; real hardware comes in the next unit.
Tinkercad: Arduino Uno R3 is in the components list; Code › Blocks + Text shows the generated C++ beside the blocks (it can't be edited until you switch to Text). Same class code as the micro:bit unit.
Running the lesson
Predict: ask students to point at the pin number in each line of the sketch.
Find the mistake: the dim glow is a real effect students will see on hardware; name it the pull-up.
Tinkercad: ask which block made which line of C++.
The hard part (on purpose)
C++ looks dense after blocks. Read it aloud line by line and point at the pin number in each.
When students get stuck
A student changes only pinMode. Ask: Which pin does each digitalWrite line switch? Fix: Every line that names a pin.
Upload fails with a ; error. Ask: Which line does the message name, and how does it end? Fix: Every statement ends with ;
Stretch and support
Stretch: Wire a second LED on pin 9 and blink them in turn.
Support: A printed sketch with the pin numbers highlighted.
Where it leads
Next: Reading the C++ (what setup() and loop() do, and timing with delay).
Circuits with the micro:bit: the same loop and resistor ideas.
which pin?: Committing to what happens when the code names a different pin from the wire tests the new move: pin numbers in code must match the wiring. The wrong options are the 'code works whatever pin' picture.
Try: run it: Running the sketch settles the prediction: the board shows pin 13 not wired, and the LED on pin 12 never changes.
Worked example: read the pins: Reading each line for its pin number models the move: every pin number must be the wired pin. Sam's half-changed sketch is planted after the method, with its real symptom (a dim glow from the pull-up).
Vary: change the pin: Changing every pin number in the code, then running it, applies the move directly.
Build it in Tinkercad: Building the circuit on an Uno in Tinkercad with blocks, then opening the Blocks + Text view, shows that the blocks are this C++.
pins: Reading pin numbers and modes in short sketches, with the pull-up glow as the symptom of a missing pinMode.
your own sketch: Writing pinMode and digitalWrite from scratch for a new pin puts the lesson's two lines together without a model to copy.