What Is Code? Instructions a Robot Can Follow
Code Is Just Very Precise Instructions
At its core, code (a program) is a list of precise, unambiguous instructions that a computer — or in our case, a microcontroller — follows exactly, in order, one at a time. There's no guessing, no "figure out what I meant" — the microcontroller does EXACTLY what the code says, which is both its greatest strength and the reason bugs happen.
A Human Instruction vs a Code Instruction
Imagine telling a friend: "Make me a sandwich." Your friend fills in a hundred unstated assumptions — use bread, use a plate, don't use rotten ingredients. A robot's brain fills in NONE of that. If you don't explicitly tell it, it doesn't know. This is the single hardest mental shift for new programmers: you must say exactly what you mean, because nothing is assumed.
Programs Run Top to Bottom (Usually)
A basic program runs its instructions in order, from top to bottom, exactly once through — unless you use special instructions (which you'll meet in the next two lessons) to repeat parts of it or skip parts of it based on a condition.
Two Special Parts of an Arduino-Style Program
Arduino programs are traditionally split into two parts:
- Setup — code that runs ONCE, right when the robot powers on (for example, telling the Arduino which pins are inputs and which are outputs)
- Loop — code that runs OVER AND OVER, forever, for as long as the robot has power (this is literally where the sense-think-act loop from Module 1 lives in real code!)
This structure exists because robots genuinely need both: some things (like configuring pins) only need to happen once, while sensing, thinking, and acting need to happen continuously.
Why "Precise" Beats "Clever"
New programmers often try to write clever, complicated code to look impressive. Experienced engineers know that clear, precise, simple code that does exactly what's needed — and is easy to read back and check — is far more valuable, especially when something goes wrong and you need to figure out why.
Key Takeaway
Code is not magic — it's an extremely precise, unambiguous list of instructions. The robot will do EXACTLY what you tell it, which means your job as a programmer is to think through exactly what you actually want, in a level of detail you may not be used to in everyday conversation.
Sign up free to carry on with the course, with an AI tutor to help you.
Continue the course
