ESP32_Mini_16x16_v2 — Xiao Esp32 C3 simulation

An interactive Xiao Esp32 C3 circuit simulation you can run free in your browser on Velxio, by frank-oenings.

Components

Sketch code

#include <Adafruit_NeoPixel.h>

uint32_t i=0;

#define PIN 21              // WS2812 NeoPixel
#define NUMPIXELS 256       // Anzahl
#define MATRIX_WIDTH  16   // Physikalische Breite der Matrix
#define MATRIX_HEIGHT 16   // Physikalische Höhe der Matrix

Adafruit_NeoPixel matrix = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

// Farbdefinition (RGB)
const uint32_t FARBE_AN = matrix.Color(0, 0, 50);
const uint32_t FARBE_AUS = matrix.Color(0, 0, 0);

uint32_t warte=500;        // 500 Millisekunden Pause 
void setup()
{
  matrix.begin();         // Initialisierung
  matrix.show();          // Alle LEDs initial aus
}

void schalteBuchstabeEin(int x, int y) {

  int physY1 = y * 2;
  int physY2 = (y * 2) + 1;

  int ledIndex1, ledIndex2;

  if (physY1 % 2 == 0) {
    // Von links nach rechts
    ledIndex1 = physY1 * MATRIX_WIDTH + x; 
  } else {
    // Von rechts nach links
    ledIndex1 = physY1 * MATRIX_WIDTH + (MATRIX_WIDTH - 1 - x); 
  }

  if (physY2 % 2 != 0) {
    ledIndex2 = physY2 * MATRIX_WIDTH + x;
  } else {
    ledIndex2 = physY2 * MATRIX_WIDTH + (MATRIX_WIDTH - 1 - x);
  }

  // Beide LEDs für diesen Buchstaben einschalten
  matrix.setPixelColor(ledIndex1, FARBE_AN);
  matrix.setPixelColor(ledIndex2, FARBE_AN);
}

void loop()
{
  // Test
  for (int k=0; k<8; k++)
  {
    for (int i=0; i<16; i++)
    {
      schalteBuchstabeEin(i, k);
      matrix.show();
      delay (warte);
    }
  }
}

More projects by frank-oenings