Asia/Kolkata
Posts

Embedded Systems for Beginners: Blinking LEDs and Beyond

March 1, 2025
Embedded systems are everywhere, ranging from smart thermostats to automotive engine control units. If you are used to writing code that runs in a browser or on a server, writing code that interacts with physical pins, registers, and components can feel like a different world. You don't need a degree in electrical engineering to get started. Learning how a microcontroller reads inputs (sensors) and writes outputs (relays, LEDs) is enough to start building functional hardware projects. Here is a practical breakdown of the hardware, with three projects that cover the fundamentals. For beginners, starting with a standard development board is much easier than programming a bare chip on a breadboard.
  • Arduino Uno: The industry standard for beginners. It runs on an 8-bit AVR microcontroller (ATmega328P), operates at 5V, and has a large library ecosystem. It lacks built-in connectivity.
  • ESP32: A significant step up. It features a dual-core 32-bit processor, runs at 3.3V, and has built-in Wi-Fi and Bluetooth. It is the default board for IoT projects.
  • Raspberry Pi Pico: A low-cost, high-performance board built around the RP2040 chip. It supports C/C++ and MicroPython, making it very flexible.
The examples below use the Arduino framework for its simplicity and wide support.
The traditional starting point is blinking an LED. This circuit builds on that by transitioning from a simple digital blink to analog-style fading using Pulse Width Modulation (PWM).
  • 1x Arduino Uno or compatible board
  • 1x LED (any color)
  • 1x $220,\Omega$ current-limiting resistor
  • Breadboard and jumper wires
Connect the positive leg (anode, longer leg) of the LED to Digital Pin 9 on the Arduino. Connect the negative leg (cathode, shorter leg) to one side of the $220,\Omega$ resistor, and connect the other side of the resistor to the GND pin of the Arduino. Instead of turning the LED fully on and off, we use analogWrite() to vary the duty cycle and create a fading effect.
This project introduces digital communication protocols. We read data from a DHT11 sensor and display it on a $16\times2$ character LCD using the $I^2C$ protocol.
  • 1x Arduino Uno
  • 1x DHT11 Temperature and Humidity Sensor
  • 1x $16\times2$ LCD screen with $I^2C$ backpack (reduces the required pins from 12 to just 4)
  • Jumper wires
  • DHT11: Connect VCC to 5V, GND to GND, and Data to Digital Pin 2.
  • LCD ($I^2C$): Connect VCC to 5V, GND to GND, SDA (Serial Data) to Analog Pin A4, and SCL (Serial Clock) to Analog Pin A5.
You will need the DHT sensor library by Adafruit and the LiquidCrystal_I2C library installed in your Arduino IDE. Now we use the ESP32 to serve a simple web page that controls an output pin over your local network.
  • 1x ESP32 Development Board
  • 1x Relay Module or a simple LED (we'll control GPIO Pin 2, which is often connected to the built-in LED)
Select your ESP32 board in the IDE. Replace YourWiFiSSID and YourWiFiPassword with your local network details. Upload the sketch, open the Serial Monitor at 115200 baud to find the IP address, and open that IP in a phone or laptop browser to control the pin.
Hardware issues can come from both code and physical wiring.
  1. Board Not Detected: Check your USB cable, as some are power-only and carry no data. Make sure you have the correct driver (CH340 or CP2102) installed for your board.
  2. Floating Inputs: If you read a digital pin connected to a button and the state bounces randomly between HIGH and LOW, the pin is "floating." Use an internal pull-up resistor (pinMode(pin, INPUT_PULLUP)) to pull the pin to a known state when the button is open.
  3. No Display on LCD: Adjust the small potentiometer on the back of the $I^2C$ module. If the contrast is set incorrectly, the characters will be invisible.