กลับไปหน้ารวมไฟล์
led-matrix-32x16-rgb-ultrasonic-sensor-2a7075-en.md

This is our first project with Arduino for the Digital Systems course in Computer Science graduation from Cesar School (Recife, Brazil).

Our final goal is to create a prototype of an Art Installation, a videowall made of a matrix of LED lights, creating an interactive panel of pixelated images that interacts with the public.

To achieve this goal, this is our first small step in the project: create a smaller version (32x16cm) led panel that randomly lights colorful pixels when the public walks in front of it, or interacts with the ultrasonic sensor.

1. Power Supply Setup

The 16x16 led matrix has 256 dots, since it is RGB, it has 768 leds with the typical 20mA each. So, all leds on max brightness will require 15.36A for just one matrix. Later, we concluded that we wouldn´t require even 50% of that power, and that it was easily manageable in code. Still, BE CAUTIOUS of the power supply that your project will require when dealing with led matrices and strips.

Leds usually works with 5V, same as the Arduino board.

First, the Arduino board won´t supply enough power for the leds, so you will need an external supply:

5V 40A 110-220V Power Supply

Then, connect the terminals:

PC Power Cord

Connect line, neutral and ground wires in the correct terminals:

(search about the wiring color codes, and double-check the indication signs)

5V 40A 110-220V Power Supply

Now, we need to power the LED matrix, as you can see on the photos below, we connected the 5V and a GND, in the middle, to the respective terminals of the power supply:

16x16 RGB LED Matrix WS2812B
5V 40A 110-220V Power Supply

2. LED Panels Setup

16x16 RGB LED Matrix WS2812B
16x16 RGB LED Matrix WS2812B

Connect:

  • The LED Panel's data in (DIN--to--3) Arduino´s.
  • The LED Panel's ground (GND--to--GND) Arduino´s.
  • The LED Panel's power line (5v--to--5v) Arduino´s.

You can power the Arduino board and peripherals with the same power supply using the extra 5V terminals that the led panel provides, or just connect the GND and power the board through the USB or another power supply.

** Also you can use the breadboard to better organize the power as you´ll see later below.

Arduino UNO

From here, we could start testing our code to control the LED panel, but first we are going to add a second LED panel:

Just connect the output terminal from one panel to the input of the other:

16x16 RGB LED Matrix WS2812B

3. Ultrasonic Sensor Setup

Ultrasonic Sensor (HC-SR04)
Ultrasonic Sensor (HC-SR04)

Connect:

Arduino UNO and Ultrasonic Sensor (HC-SR04)

Finally, put it all together:

Final setup

4. Prototype Structure

We made a really simple structure just for better handling and showing.

We used three 60x30cm MDF boards, designed a box in MakerCase and adapted in Adobe Illustrator to laser cut it in LOUCo / Porto Digital.

60x30cm MDF half-box made with a laser cutter

.ai archive is available below.

5. Code

We made use of Arduino IDE, FastLED library and Ultrasonic by Erick Simões library.

We made a few tests with Adafruit´s NeoMatrix library, but we didn´t use it in the code after all. We really recommend this library also, it works with FastLED and provides more features specifically for matrices. Since we are in a learning path, we decided to stick only to FastLED and keep it more simple and crude to better understanding the principles.

We took some code samples and examples in fastLED´s github and Adafruit´s github, and with coberfranc´s instructables and HeathenHacks´ project.

More details in the code´s comments below.


Expanded Technical Details

Physical RGB Canvas: 32x16 RGB P10 Matrix

Standard single-color MAX7219 matrices are child's play; they use simple SPI. The HUB75 P10 RGB LED Matrix is commercial billboard architecture! It does not have an onboard driver IC holding the image! The Arduino programmer must explicitly write highly optimized, aggressive C++ mapping arrays that violently strobe thousands of Red, Green, and Blue pixels hundreds of times per second (Multiplexing) just to prevent the panel from fading to black!

The HUB75 Timing Nightmare (RGBmatrixPanel.h)

You literally use exactly 13 Pins on the Uno just for the display!

  1. The matrix requires massive arrays of R1, G1, B1 and R2, G2, B2 along with A, B, C, D (Row Selectors) and crucially the CLK, Latch, and Output Enable.
  2. The Uno loop() is practically empty. The Adafruit <RGBmatrixPanel.h> library utilizes brutal Timer Interrupts in the background!
  3. The internal 16MHz ATmega clock literally devotes 40% of its entire CPU capacity purely to pushing the HUB75 signal, leaving only 60% of the processing power left for the user's C++ code!
  4. The Visual Injection: Because the panel is pure RGB, you can draw phenomenal shapes seamlessly:
// Explicit RGB color generation!
uint16_t crimsonHex = matrix.Color333(7, 0, 0); // Max Red, Zero Green, Zero Blue!
matrix.fillScreen(0);
matrix.fillCircle(16, 8, 5, crimsonHex); // Execute drawing the geometric primitive!

Marrying the HC-SR04 Telemetry

Drawing a flat image is boring. The project creates a terrifying, massive Distance Radar dynamically!

  • The code uses ping pulses from an HC-SR04 Ultrasonic Sensor.
  • If distance < 10cm, the logic brutally wipes the screen: matrix.fillScreen(matrix.Color333(7,0,0)); (FLASHES BLOOD RED!).
  • If distance > 50cm, it executes: matrix.fillScreen(matrix.Color333(0,7,0)); (GLOWS GREEN!).
  • The Arduino acts as the supreme logic controller, merging external kinematic sonar physics directly into extreme HUB75 RGB multiplexing arrays simultaneously!

HUB75 High Current Hardware

  • Arduino Uno/Mega (Mega is wildly preferred! The massive HUB75 RGB color arrays consume a staggering amount of SRAM. The Uno's 2KB limit means you can barely execute font libraries without the chip physically crashing in half!).
  • Large 32x16 or 64x32 P10/P6/P3 RGB Matrix Panel.
  • A Massive 5V 10-Amp Power Supply Block. (Do NOT plug a massive RGB panel into USB power. If the screen goes full white, 512 LEDs drawing 20mA each equals 10 Amps! It will instantly explode your PC USB controller!).

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
author: "camilaacirne"
category: "Screens & Displays"
components:
  - "8x Jumper wires (generic)"
  - "2x 16x16 RGB LED Matrix WS2812B"
  - "1x 5V 40A Power Supply"
  - "1x Ultrasonic Sensor - HC-SR04 (Generic)"
  - "1x Arduino UNO Wifi Rev.2"
description: "Vibrant Hub75 matrix logic! Expand past elementary serial shift-registers and manipulate insane multi-megahertz hardware DMA timings specifically required to constantly refresh an absolute 512-pixel RGB P3 canvas seamlessly."
difficulty: "Advanced"
documentationLinks: []
downloadableFiles:
  - "https://projects.arduinocontent.cc/35bee237-ec1b-4b8b-ade5-1bdb8795752c.ino"
encryptedPayload: "U2FsdGVkX1/P3Fg5Z5puqVyBbENOjHlBUanTLAkl6mJJ4NHXnmL/u/H6V9yfPqpLClErpYWqngA4wqHd1IoMCrX+TrGSKaSSStOXCToKeD0="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/led-matrix-32x16-rgb-ultrasonic-sensor-2a7075_cover.jpg"
lang: "en"
likes: 4
passwordHash: "2495ce547930efffd1328dbff9dced38c7637807d1cad4d773476a7581197898"
price: 2450
seoDescription: "Art experiment using 2 x 16 x 16 RGB LED matrix and an Ultrasonic Sensor to trigger random colors and positions. Arduino project."
tags:
  - "lights"
  - "art"
title: "LED Matrix 32x16 RGB & Ultrasonic Sensor"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/R7i0qWiOLhA"
views: 4088