Мы пытаемся закодировать два NeoPixel Adafruit 8x8, но только один из них светится заданным нами узором. Мы хотим, чтобы другой отражал тот же шаблон, но имеющийся у нас код не работает. Мы попытались сделать так, чтобы Arduino воспринимал это как одну сеточную плату со 128 точками, но нам это не удалось.
Мы будем признательны за любую информацию.
Мы пытаемся закодировать два NeoPixel Adafruit 8x8, но только один из них светится заданным нами узором. Мы хотим, чтобы другой отражал тот же шаблон, но имеющийся у нас код не работает. Мы попытались сделать так, чтобы Arduino воспринимал это как одну сеточную плату со 128 точками, но нам это не удалось. Мы будем признательны за любую информацию. [code]#include
#define PIN 6 // Pin where NeoPixel is connected #define NUMPIXELS 128 // Number of pixels in 8x8 grid * 2 #define GRID_WIDTH 8 // Width of the grid
void drawPattern(int offsetX, int offsetY) { pixels.clear();
for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { int pos1 = (y + offsetY) * GRID_WIDTH + (x + offsetX); int pos2 = pos1 + 64; // The second grid starts after the first 64 pixels if (pos1 >= 0 && pos1 < 64) { // Ensure within first grid bounds pixels.setPixelColor(pos1, color_pattern[y][x]); // Set each pixel to its respective color } if (pos2 >= 64 && pos2 < 128) { // Ensure within second grid bounds pixels.setPixelColor(pos2, color_pattern[y][x]); // Set each pixel to its respective color for the second grid } } } pixels.show(); }
void loop() { pixels.setBrightness(40); drawPattern(posX, posY); delay(500); // Delay to see movement
// Update position posX += 1; // Move right if (posX > GRID_WIDTH - 8) { // If at the right edge, move down and reset X posX = 0; posY += 1; } if (posY > GRID_WIDTH - 8) { // If at the bottom edge, reset Y posY = 0; } } [/code] [img]https://i.sstatic.net/fzk8DGV6.jpg[/img]