Home/Articles/Controllers and robotics

The microcontroller: the tiny computer that moves the robot

Inside a washing machine, a toy and a thermometer there is a small chip that reads, decides and acts. Meet the microcontroller and learn how to get started with it.

Illustration generated by code.

What is it?

A microcontroller is a single chip that contains a small processor, memory, and input and output pins. It is not as powerful as your laptop, but it is cheap, uses little power, and is designed for one job that it repeats without stopping.

Well-known examples in education include Arduino boards, ESP32 boards, which add wireless connectivity, and the Raspberry Pi Pico.

Read, decide, act

Most microcontroller programs are a simple loop that repeats:

  • Read: a value from a sensor, such as light level, distance or temperature.
  • Decide: compare the value with a condition, such as "if the light is below a certain limit."
  • Act: turn on a light, move a motor, or send a reading.

This loop is the foundation of a line-following robot, a system that waters a plant, and a device that sounds an alarm.

Digital and analog

A digital pin knows only two states: on or off. An analog sensor, on the other hand, gives a varying voltage, which the microcontroller turns into a number through a built-in converter. On many boards this number ranges from 0 to 1023, and on other boards from 0 to 4095.

How to start safely

Start with an LED and a resistor, then a button, then a light sensor. Work at low voltages from a USB port or small batteries, and never connect the microcontroller directly to household mains power or to a large motor without a suitable driver circuit. And disconnect the power before changing any connections.

An educational article written by the Madar team to simplify a scientific idea. Madar is a center in its founding stage, and what appears here about its programs consists of proposed plans.