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.
/*
* 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.