Arduino-Controlled Dual WS2812 RGB LED Matrix Eye Animation Display
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control two 8x8 WS2812 RGB LED matrices using an Arduino UNO microcontroller. The purpose of the circuit is to create a slow blinking human eyes effect, with the first LED matrix connected directly to the Arduino and the second matrix daisy-chained to the first. The Arduino UNO controls the LED matrices through one of its digital pins using a custom sketch written in the Arduino programming environment.
Component List
WS2812 RGB LED matrix 8x8
- Description: An 8x8 matrix of WS2812 RGB LEDs, each individually addressable.
- Pins: DIN (Data Input), VCC (Power Supply), GND (Ground), DOUT (Data Output)
Arduino UNO
- Description: A microcontroller board based on the ATmega328P, widely used for building digital devices and interactive objects.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5 (Analog Input), SCL, SDA, AREF, D0-D13 (Digital I/O)
Wiring Details
WS2812 RGB LED matrix 8x8 (First Matrix)
- DIN: Connected to Arduino UNO's digital pin D7.
- VCC: Connected to Arduino UNO's 5V pin.
- GND: Connected to Arduino UNO's GND pin.
- DOUT: Connected to the DIN of the second WS2812 RGB LED matrix 8x8.
WS2812 RGB LED matrix 8x8 (Second Matrix)
- DIN: Connected to DOUT of the first WS2812 RGB LED matrix 8x8.
- VCC: Connected to VCC of the first WS2812 RGB LED matrix 8x8.
- GND: Connected to GND of the first WS2812 RGB LED matrix 8x8.
- DOUT: Not connected to any other components in this circuit.
Arduino UNO
- D7: Connected to DIN of the first WS2812 RGB LED matrix 8x8.
- 5V: Connected to VCC of the first WS2812 RGB LED matrix 8x8.
- GND: Connected to GND of the first WS2812 RGB LED matrix 8x8.
- Other Pins: Not used in this circuit.
Documented Code
/*
* Arduino Sketch to control two 8x8 WS2812 RGB LED matrices to create a
* slow blinking human eyes effect. The first matrix is connected to pin D7 of the
* Arduino UNO, and the second matrix is daisy-chained to the first.
*/
#include <Adafruit_NeoPixel.h>
#define PIN 7
#define NUMPIXELS 128 // 2 matrices of 8x8 LEDs
#define BRIGHTNESS 128
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pixels.begin(); // Initialize the NeoPixel library.
pixels.setBrightness(BRIGHTNESS);
}
void loop() {
slowBlinkEyes();
}
void slowBlinkEyes() {
// Define the eye shape pattern
int eyeOpen[8][8] = {
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 0, 0, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 0, 0, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 0, 0}
};
int eyeHalfClosed[8][8] = {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 0, 0, 1, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 0, 0, 0, 0, 1, 1},
{1, 1, 1, 0, 0, 1, 1, 1}
};
int eyeClosed[8][8] = {
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
};
displayPattern(eyeOpen);
delay(500); // Eyes open for 500ms
displayPattern(eyeHalfClosed);
delay(500); // Eyes half-closed for 500ms
displayPattern(eyeClosed);
delay(500); // Eyes closed for 500ms
displayPattern(eyeHalfClosed);
delay(500); // Eyes half-closed for 500ms
displayPattern(eyeOpen);
delay(500); // Eyes open for 500ms
}
void displayPattern(int pattern[8][8]) {
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 8; x++) {
int pixelIndex1 = y * 8 + x;
int pixelIndex2 = 64 + y * 8 + x;
if (pattern[y][x] == 1) {
pixels.setPixelColor(pixelIndex1, pixels.Color(255, 255, 255));
pixels.setPixelColor(pixelIndex2, pixels.Color(255, 255, 255));
} else {
pixels.setPixelColor(pixelIndex1, pixels.Color(0, 0, 0));
pixels.setPixelColor(pixelIndex2, pixels.Color(0, 0, 0));
}
}
}
pixels.show();
}
This code is responsible for creating the blinking eyes effect on the LED matrices. It includes functions for setting up the NeoPixel library, defining the eye patterns, and displaying these patterns with a slow blinking animation. The displayPattern function updates the LEDs to represent the given pattern, and the slowBlinkEyes function cycles through the patterns to simulate blinking.