Kuinka käyttää M5Stack Unit Puzzlea?

 

Mikä on Unit Puzzle?

Äskettäin M5Stack julkaisi uuden tuotteen nimeltä Unit Puzzle. Unit Puzzle on monivärinen valonohjausyksikkö, joka koostuu 8x8 RGB-matriisista, jossa on 64 WS2812E RGB-LEDiä.

M5Stack ATOM Echo

M5Stack ATOM Echo

Näytä tuote
 

Näin sen ensimmäisen kerran MakerFaire-tapahtumassa, tällaisena:

Se tekee minut iloiseksi, tiedättehän että pidämme LED-valoista kovasti, joten sain heti 10 kappaleen palapelin. Pidetään hauskaa.

  

Laitteiston liittäminen

Mikrokontrollerista, tiedättehän mikä on suosikkini. Juuri niin, M5Stack ATOM Lite.

M5Stack ATOM Lite

M5Stack ATOM Lite

Näytä tuote
 

Ja yksikkö sisälsi unit puzzlen, liittimen, Grove-kaapelin. Se tarkoittaa, että voimme yhdistää kaikki yksiköt.

Laitetaan ne yhteen.
Takaisin

 

Koodiosa

Ensimmäinen versio

//The unit puzzle used WS2812E, which means Adafruit_NeoPixel library is our best choice
#include 

//And define part:
#define PIN 26
#define NUMPIXELS 512
//The official recommendation for long-term lighting is 10% brightness, so we use 25
#define BRIGHTNESS 25 // Brightness range(0-255)

Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);


//I need display letters 'OPENELAB'
int letters[8][64] = {
  {30, 38, 21, 45, 20, 44, 19, 43, 18, 42, 17, 41, 24, 32}, // O
  {22, 30, 38, 46, 21, 45, 20, 44, 19, 27, 35, 43, 18, 17, 16}, // P
  {22, 30, 38, 46, 21, 20, 19, 27, 35, 43, 18, 17, 16, 24, 32, 40}, // E
  {22, 46, 21, 45, 20, 28, 44, 19, 27, 35, 43, 18, 34, 42, 17, 41, 16, 40}, // N
  {22, 30, 38, 46, 21, 20, 19, 27, 35, 43, 18, 17, 16, 24, 32, 40}, // E
  {22, 21, 20, 19, 18, 17, 16, 24, 32, 40}, // L
  {30, 38, 21, 45, 20, 44, 19, 27, 35, 43, 18, 42, 17, 41, 16, 40}, // A
  {22, 30, 38, 21, 45, 20, 36, 19, 27, 18, 34, 17, 41, 16, 24, 32} // B
};

//Initialize the NeoPixel library, set the brightness, turn off all pixels, call the function that displays text, and then loop empty

void setup() {
  pixels.begin();
  pixels.setBrightness(BRIGHTNESS);
  pixels.show();
  displayText();
}

void loop() {
}

// Clear all lamp beads
void displayText() {
  pixels.clear();

// Set the position of the lamp beads to display each character
  for (int charIndex = 0; charIndex < 8; charIndex++) {
    for (int i = 0; i < 64; i++) {
      if (letters[charIndex][i] != -1) {
        int pixelIndex = charIndex * 64 + letters[charIndex][i];
        pixels.setPixelColor(pixelIndex, pixels.Color(255, 0, 0)); // Sets the pixel at the specified position to red
      }
    }
  }

  pixels.show();

✔ Kopioitu!


 
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
Tämä osa on hauska. Käytin Exceliä auttamaan minua tässä. Kun unit puzzle on kytketty, sen lamput on numeroitu näin:

 

Ensimmäinen esitys

Erittäin täydellinen näyttö, mutta jokainen pikseli 0 syttyi. Liian outoa, sitä pitäisi käyttää paikannukseen. Ei se mitään, sammutetaan se.

 

Toinen versio

Minun täytyy sammuttaa pikseli 0, antaa kirjaimille eri värit.
// In the define section, increase the color cycle time by 0.5 seconds
#define COLOR_CHANGE_INTERVAL 500

// Define the character part to add characters to display red, green and blue in three colors
int letters[8][64] = {
  {30, 38, 21, 45, 20, 44, 19, 43, 18, 42, 17, 41, 24, 32}, // O
  {22, 30, 38, 46, 21, 45, 20, 44, 19, 27, 35, 43, 18, 17, 16}, // P
  {22, 30, 38, 46, 21, 20, 19, 27, 35, 43, 18, 17, 16, 24, 32, 40}, // E
  {22, 46, 21, 45, 20, 28, 44, 19, 27, 35, 43, 18, 34, 42, 17, 41, 16, 40}, // N
  {22, 30, 38, 46, 21, 20, 19, 27, 35, 43, 18, 17, 16, 24, 32, 40}, // E
  {22, 21, 20, 19, 18, 17, 16, 24, 32, 40}, // L
  {30, 38, 21, 45, 20, 44, 19, 27, 35, 43, 18, 42, 17, 41, 16, 40}, // A
  {22, 30, 38, 21, 45, 20, 36, 19, 27, 18, 34, 17, 41, 16, 24, 32} // B
};

unsigned long lastColorChangeTime = 0;
int currentColorIndex = 0;
uint32_t colors[3] = {pixels.Color(255, 0, 0), pixels.Color(0, 255, 0), pixels.Color(0, 0, 255)};

// Add switching colors in the loop
void loop() {
  unsigned long currentTime = millis();
  if (currentTime - lastColorChangeTime >= COLOR_CHANGE_INTERVAL) {
    lastColorChangeTime = currentTime;
    displayText(); 
    currentColorIndex = (currentColorIndex + 1) % 3; 
  }
}

  // Make sure the first lamp bead (pixel 0) of all matrices is off
  for (int charIndex = 0; charIndex < 8; charIndex++) {
    int firstPixelIndex = charIndex * 64;
    if (firstPixelIndex < NUMPIXELS) {
      pixels.setPixelColor(firstPixelIndex, pixels.Color(0, 0, 0));

✔ Kopioitu!
  
 

Toinen esitys

Kaunis

 

Toinen versio

  // Define the color corresponding to each character
  uint32_t characterColors[8] = {
    pixels.Color(255, 0, 0), // O - Red
    pixels.Color(0, 255, 0), // P - Green
    pixels.Color(0, 0, 255), // E - Blue
    pixels.Color(255, 255, 0), // N - Yellow
    pixels.Color(0, 255, 255), // E - Light blue
    pixels.Color(255, 0, 255), // L - Magenta
    pixels.Color(255, 128, 0), // A - Orange
    pixels.Color(128, 0, 128) // B - Purple
  };

✔ Kopioitu!
 
 

Yhteenveto

Unit Puzzle on hauska neopixel LED-matriisi. Se tekee minut iloiseksi koko päivän.

Onko sinulla muita hauskoja tapoja pelata? Jaa ne kanssamme.




 

Sivupalkki

Uusin julkaisu

Tässä osiossa ei ole tällä hetkellä sisältöä. Lisää sisältöä tähän osioon käyttämällä sivupalkkia.

Rekisteröidy uutiskirjeeseemme

Hanki viimeisimmät tiedot tuotteistamme ja erikoistarjouksistamme.