LESSON 2 (MICROCONTROLLERS – MCU)

What is the difference between your Laptop computer and a Microcontroller?

 
Both are computers, but one is a general-purpose computer (laptop/phone) and the other is a microcontroller made for controlling things in the real world. For our first projects we will be using a microcontroller called an Arduino.

Laptop / Phone:

  • Has a very powerful brain (fast processor / CPU)
  • Can do millions of things at the same time (run games, YouTube, Chrome with 50 tabs, Zoom, music, Photoshop, coding, etc.)
  • Has lots of short-term memory (RAM) so it can remember many things while working
  • Has huge long-term storage (hard drive / SSD) for saving photos, videos, games, school files
  • Runs a big operating system (Windows, macOS, Android, iOS) that manages everything
  • Needs a lot of electricity → has a big battery or needs to be plugged in often
  • Costs a lot more money
  • Gets hot when doing heavy work (that’s why laptops have fans)

Arduino: 

  • Has a small, simple brain (much slower processor)
  • Can only do one main job at a time really well (read a sensor, blink an LED, spin a motor, play a tone…)
  • Has very little short-term memory (only 2 KB–32 KB of RAM on most models — tiny!)
  • Has almost no long-term storage (just 32 KB–512 KB of flash memory for your program — like a very small notebook)
  • Doesn’t run Windows, Android, or any big operating system — it just runs your one program forever (or until power is cut)
  • Uses very little electricity → can run for weeks or months on a couple of AA batteries
  • Costs a lot less 
  • Almost never gets hot
The Arduino CPU is smaller than your thumbnail. It only knows how to follow the instructions you give it:
  • The Arduino microcontroller is like a tiny chef who is really good at following recipes, but it doesn’t know any recipes itself.
  • You write the recipe (the program) on your big computer (laptop or desktop) using special blocks or words.
  • You send the recipe to the Arduino through a USB cable.
  • Now the little chef (Arduino microcontroller) has the recipe forever (until you give him a new one).
  • He keeps reading the recipe over and over, super fast, and does exactly what it says:
    “If the button is pressed → turn the light on”
    “If it’s dark outside → play music”
    “Count to 10 and then spin the motor!”
LET’S GO OVER THAT ONE MORE TIME
Inside the Arduino CPU there are lots of transistors — those tiny switches we talked about — all wired together into logic gates (the AND boss, OR boss, XOR boss, and their friends). These gates are connected with fixed paths, like a giant maze of train tracks that never move. Your program is the train driver. It looks at the map (your code) and says: ‘Okay, go to the AND gate here… now take the XOR track… flip this NOT boss… and send the answer out to the motor!  The tracks stay the same forever. But your program chooses which paths the train takes and what questions to ask along the way. That’s how the same little CPU can:
 
blink an LED
spin a motor
read a sensor
move your robot’s legs

 

All just by guiding the train through the right gates at the right time — billions of switches flipping ON and OFF super fast!

Transistors = tiny ON/OFF switches

Logic gates = teams of switches with rules

CPU = giant fixed maze of gates and tracks

Your program = the driver who decides the route

Inside the Arduino brain there is also:

  • A little memory to remember your recipe (program).
  • Pins (like little fingers) that can turn things ON or OFF, read if something is pressed, or measure temperature/light
ARDUINO NANO

Let’s take a closer look at the Nano.