Try Embedded

Arduino and ESP32 example projects

211 example projects, one for every part and for firmware techniques from watchdogs to PID, each with its circuit, full code and how it works.

Output

Input

Logic

Sensors

Displays

Communication

Motors

Industrial

RTOS

Firmware

Control

  • Motor speed PID (encoder and flywheel) · Hold a 12 V motor at a set speed: count its encoder on interrupts, add a feedforward, close a PI loop, and tune it live while a load pulls on the shaft.
  • Heater PID (lag, dead time and a door) · Hold an aluminium block at 60 °C with a 20 W heater and an LM35: a slow plant whose sensor lags and whose heat arrives late, and a door that opens.
  • Line follower: bang-bang, then PD · A two-wheel robot follows black tape round a 1.6 m oval: first bang-bang, which zigzags and loses the line on the bends, then PD on the line's position from all five IR sensors, tuned live from the World tool.
  • Obstacle avoider with an ultrasonic sensor · A two-wheel robot roams a room of boxes: it pings ahead with its ultrasonic sensor every 60 ms, turns on the spot when something is closer than 35 cm, and drives on once the way is clear.
  • ESP32-C3 line follower with wheel encoders · The two-wheel robot on an ESP32-C3: five IR readings on its 12-bit ADC, PD steering on LEDC PWM, and the wheels counted on interrupts from slotted encoder discs slow enough for its pins.
  • Nucleo-F401RE line follower in bare-metal C · The two-wheel robot on a Nucleo-F401RE, registers only: ADC1 reads the five IR sensors in turn, TIM2 makes the two motors' PWM, and TIM3 and TIM1 count the wheel encoders in hardware, in encoder mode.
  • Pico line follower in MicroPython · The two-wheel robot on a Raspberry Pi Pico in MicroPython: three IR sensors on its ADC, the outer two through their comparators, PD steering on two PWM outputs, all in one polled loop.
  • Water tank level (PI, anti-windup, a drain) · Hold a water column at 150 mm with a 12 V pump and a level sensor: a slow, non-linear plant, a PI loop that must not wind up while it fills, a float switch as the safety stop, and a drain to open.
  • Pico water tank in MicroPython · The water tank's level loop on a Raspberry Pi Pico in MicroPython: the level sensor on its ADC, the pump's MOSFET on a PWM output, the float switch polled, and gains you can change over the REPL's serial line.
  • Cart-pole balance (state feedback) · Balance a 300 mm pole on a belt-driven cart: two quadrature encoders on interrupts, a 2 ms loop, and full state feedback on the pole's angle and rate and the cart's place and speed. Nudge it and watch it recover. A Pro rig.
  • Nucleo-F401RE cart-pole in bare-metal C · Balance the cart-pole on a Nucleo-F401RE with registers only: TIM3 and TIM1 count both encoders in hardware, in encoder mode, TIM2 makes the motor's PWM, and SysTick runs the state-feedback loop every 2 ms. A Pro rig.

Basic