Raspberry Pi GPIO Multi-LED Control System – Beginner-Friendly Embedded Electronics Project

Raspberry Pi GPIO Multi-LED Control System | MakeMindz
🍓 Raspberry Pi Project

Raspberry Pi GPIO Multi-LED Control System

Build a sequential LED chaser using Raspberry Pi 2B GPIO pins — complete with circuit diagram, wiring guide, and code.

Beginner-friendly 10 LEDs controlled Arduino/GPIO sketch included ~30 min build time

Project Overview

This project demonstrates how to control 10 LEDs (8 red + 2 yellow) using the GPIO pins on a Raspberry Pi 2 Model B. Each LED is connected through a current-limiting resistor on a breadboard. A loop in the Arduino/GPIO sketch sequentially turns each LED on and off, creating a chaser effect — similar to traffic lights or embedded status indicators.

🔌

GPIO Output Control

Drive 3.3V HIGH/LOW signals directly from Pi GPIO pins to LEDs via resistors.

💡

LED Chaser Effect

Sequential 500ms on/off timing creates a looping light-show animation.

🧩

Expandable Design

Add sensors, buttons, or IoT connectivity to turn this into a smart system.

📚

STEM Learning

Ideal for classrooms, lab experiments, and learning embedded electronics fundamentals.

Components Required

Component Specification Qty Purpose
Raspberry Pi 2 Model B Any Pi with GPIO header ×1 Main controller
Red LED 5mm, standard, 2V forward voltage ×8 GPIO pins 26, 19, 13, 6, 5, 21, 20, 16
Yellow LED 5mm, standard, 2V forward voltage ×2 GPIO pins 7, 8
Resistor 220Ω or 330Ω, ¼W ×10 Current limiting (one per LED)
Breadboard Half-size (400 tie points) or larger ×1 Circuit prototyping
Jumper wires Male-to-female, assorted lengths ×20 Connections from Pi to breadboard
Micro USB power supply 5V / 2A minimum ×1 Power the Raspberry Pi
⚠️ Resistor selection: Always use a current-limiting resistor with each LED. For a 3.3V GPIO output and a 2V LED forward voltage, a 220Ω resistor limits current to ~6mA — safe for both the GPIO pin (max ~16mA) and the LED.

Circuit Diagram

The diagram below shows how each LED is wired to a GPIO pin through a 220Ω resistor. All LED cathodes (negative legs, shorter leg) connect to GND.

GPIO Multi-LED Circuit — Raspberry Pi 2B Raspberry Pi 2B GPIO Header GPIO 26 GPIO 19 GPIO 13 GPIO 6 GPIO 5 GPIO 21 GPIO 20 GPIO 16 GPIO 7 GPIO 8 GND Breadboard + (3.3V / not used) – (GND rail) 220Ω LED1 220Ω LED2 220Ω LED3 220Ω LED4 220Ω LED5 220Ω LED6 220Ω LED7 220Ω LED8 220Ω LED9 Y 220Ω LED10 Y GND Rail (all cathodes) Legend GPIO signal wire Yellow LED wire GND wire Red LED Yellow LED 220Ω Resistor Cathode to GND GPIO Pin Map 26 → Red LED 1 19 → Red LED 2 13 → Red LED 3 6 → Red LED 4 5 → Red LED 5 21 → Red LED 6 20 → Red LED 7 16 → Red LED 8 7 → Yellow LED 9 8 → Yellow LED 10

Figure 1: Schematic — each LED connects through a 220Ω resistor from a GPIO pin to the GND rail. All 10 LED cathodes share the common GND rail.

📐
diagram.json — The structured circuit data below describes every connection in machine-readable format, compatible with Cirkit Designer, Fritzing-style imports, and custom tools.

Step-by-Step Wiring Guide

Safety first: Always power off or unplug the Raspberry Pi before connecting or disconnecting components from the GPIO header.
  • 1

    Place all 10 LEDs on the breadboard

    Insert 8 red LEDs and 2 yellow LEDs into the breadboard across different rows. Ensure each LED spans the center divider — anode (longer leg, +) on one side, cathode (shorter leg, –) on the other.

  • 2

    Connect a 220Ω resistor to each LED anode

    Place one 220Ω resistor in series with the anode (longer leg) of each LED. The resistor's other end will connect to the GPIO pin wire. This limits current to ~6mA per LED, within the safe operating range of GPIO pins.

  • 3

    Connect all LED cathodes to the GND rail

    Use short jumper wires to connect the cathode (short leg) of every LED to the breadboard's negative (–) power rail. This is the shared GND connection.

  • 4

    Wire GPIO pins to resistors with male-to-female jumpers

    Connect male-to-female jumper wires from the Raspberry Pi GPIO pins to the free end of each resistor. Follow the pin map: GPIO 26 → LED 1 resistor, GPIO 19 → LED 2 resistor, and so on down to GPIO 8 → LED 10 resistor.

  • 5

    Connect GND rail to Pi GND pin

    Run a jumper wire from the breadboard's GND rail to any GND pin on the Raspberry Pi GPIO header (e.g., physical pin 6, 9, 14, 20, 25, 30, 34, or 39). This completes the circuit.

  • 6

    Double-check all connections before powering on

    Verify each resistor is between the GPIO pin wire and the LED anode — never between the cathode and GND. Confirm LED polarity. Check that no bare wires short across adjacent GPIO pins.

  • 7

    Upload the sketch and power the Raspberry Pi

    Flash the Arduino sketch (shown below) to the Pi GPIO system, or run the Python equivalent. Power on the Pi via Micro USB. The LEDs should begin sequencing one by one every 500ms.

GPIO Pin Reference

GPIO 26
Red LED 1
GPIO 19
Red LED 2
GPIO 13
Red LED 3
GPIO 6
Red LED 4
GPIO 5
Red LED 5
GPIO 21
Red LED 6
GPIO 20
Red LED 7
GPIO 16
Red LED 8
GPIO 7
Yellow LED 9
GPIO 8
Yellow LED 10
GND
Any GND pin

The Code

The sketch initializes each GPIO pin as OUTPUT in setup(), then loops through all 10 LEDs sequentially — turning each on for 500ms, then off for 500ms — creating a continuous chaser effect.

ARDUINO / C++
/*
 * Raspberry Pi GPIO Multi-LED Control System
 *
 * Controls 10 LEDs (8 red + 2 yellow) via GPIO pins.
 * Each LED is connected through a 220Ω current-limiting resistor.
 * The loop creates a sequential chaser effect with 500ms timing.
 *
 * Pin assignments:
 *   Red LEDs:    GPIO 26, 19, 13, 6, 5, 21, 20, 16
 *   Yellow LEDs: GPIO 7, 8
 *   GND:         Any GND pin on GPIO header
 */

void setup() {
  // Initialize all GPIO pins as digital outputs
  pinMode(26, OUTPUT);  // Red LED 1
  pinMode(19, OUTPUT);  // Red LED 2
  pinMode(13, OUTPUT);  // Red LED 3
  pinMode(6,  OUTPUT);  // Red LED 4
  pinMode(5,  OUTPUT);  // Red LED 5
  pinMode(21, OUTPUT);  // Red LED 6
  pinMode(20, OUTPUT);  // Red LED 7
  pinMode(16, OUTPUT);  // Red LED 8
  pinMode(7,  OUTPUT);  // Yellow LED 1
  pinMode(8,  OUTPUT);  // Yellow LED 2
}

void loop() {
  // Array of all GPIO pins in sequence
  int ledPins[] = {26, 19, 13, 6, 5, 21, 20, 16, 7, 8};
  int numLeds = sizeof(ledPins) / sizeof(ledPins[0]);

  // Sequentially blink each LED with 500ms on / 500ms off
  for (int i = 0; i < numLeds; i++) {
    digitalWrite(ledPins[i], HIGH);  // Turn LED ON (3.3V)
    delay(500);                        // Wait 500ms
    digitalWrite(ledPins[i], LOW);   // Turn LED OFF (0V)
    delay(500);                        // Wait 500ms
  }
}
🐍 Python alternative: You can run the same logic using RPi.GPIO or gpiozero libraries directly on the Raspberry Pi. Use GPIO.output(pin, GPIO.HIGH) and time.sleep(0.5) to replicate the sketch behaviour.

How the timing works

Each iteration of the for loop takes 1 second (500ms ON + 500ms OFF). With 10 LEDs, one full pass through all LEDs takes 10 seconds, then it repeats continuously. Adjust the delay() value to change speed.

Simulation Links

Test and verify the circuit in browser-based simulators before building on real hardware. Both tools let you place components, wire them up, and run the code without any physical parts.

🔬

Cirkit Designer — Online Simulation

Drag-and-drop Raspberry Pi + LEDs + resistors. Paste the sketch, click Run, and watch the LEDs sequence in real time.

Open Cirkit Designer

Wokwi — Free Raspberry Pi Simulator

Wokwi supports Raspberry Pi Pico and GPIO simulation with MicroPython or C. Ideal for testing GPIO LED chaser patterns instantly.

Open Wokwi
💡 Simulation tip: In Cirkit Designer, search for "Raspberry Pi 2B" in the component library. Add LEDs and resistors, wire them to GPIO pins matching the pin map above, paste the sketch into the code panel, and press Simulate.

How It Works

GPIO Digital Output

The Raspberry Pi's GPIO pins can be set as either INPUT or OUTPUT. In OUTPUT mode, writing HIGH sends 3.3V to the pin, and LOW sends 0V (ground). This voltage difference is what turns an LED on or off.

Current Limiting

LEDs require a specific forward current (typically 10–20mA) and have a forward voltage of around 2V. The GPIO output is 3.3V, so the remaining 1.3V must be dropped across the resistor. Using 220Ω: I = 1.3V ÷ 220Ω ≈ 5.9mA — safe for both the LED and the GPIO pin (max 16mA per pin).

Sequential Chaser Logic

The ledPins[] array stores all 10 pin numbers. The for loop iterates through each, sending HIGH then LOW with delays. Only one LED is on at any given moment, creating the chaser pattern. The infinite loop() function repeats this forever.

Learning Outcomes

Understanding Raspberry Pi GPIO pin configuration and digital output modes
Basic electronics: forward voltage, current limiting, resistor selection
Breadboard prototyping and hardware connection best practices
Loop-based automation and timing logic in embedded systems
Software-to-hardware interaction and the concept of digital signals
Using arrays and loops to manage multiple outputs efficiently

Extensions & Next Steps

🔘

Add a Push Button

Wire a button to a GPIO input pin and start/stop the sequence on press.

🌡️

Sensor-Triggered LEDs

Connect a DHT11 or PIR sensor — light specific LEDs based on readings.

📡

IoT Dashboard Control

Add Wi-Fi via ESP8266 and control LEDs from a cloud dashboard remotely.

🎨

PWM Brightness Control

Use analogWrite() / PWM to dim LEDs smoothly, not just on/off.


Comments

try for free