Have Fun with M5Stack Unit NeoHEX

Today we want to do something simple, so I choose the M5Stack Unit NeoHEX. It's a newbie-friendly product. Let's do it now.
M5Stack Glass Unit

M5Stack ATOM Lite

View Product
M5Stack Speaker 2 Hat

M5Stack Neo HEX

View Product
I'd like to use M5Stack ATOM Lite be a micro controller, this is a tiny ESP32 Pico chip product, includes 4MB SPI flash memory, it also have WiFi on board, so we can connect to our home assistant system in easy way.

Connect

First of all, we use the Grove cable Connect ATOM Lite and NeoHEX together like this:

After that, we connect ATOM Lite and our computer.
If you don't know how to upload code into M5Stack, check these articles first:

Code

Open your Arduino IDE. Don't know how to use Arduino IDE? Check this:
Libraries we need:
  1. Include libraries

#include <M5Atom.h>
#include "FastLED.h"
  1. Define hardware

#define Neopixel_PIN_26 26
#define Neopixel_PIN_32 32
#define NUM_LEDS 37
  1. Brightness

CRGB leds[NUM_LEDS];
int brightness = 128; //50% light, 0-255
  1. Setup

void setup() {
M5.begin(true, false, true); // Initialize M5Atom without Serial, I2C and LED
M5.dis.drawpix(0, CRGB::Black); // Turn off the onboard LED
// Initialize LEDs on both pins
FastLED.addLeds<WS2811, Neopixel_PIN_26, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.addLeds<WS2811, Neopixel_PIN_32, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(64);
}
  1. Loop

void loop() {
// Define the arrow pattern for your custom layout
int arrowPattern[37] = {
0, 0, 0, 0, // Row 1: 4 LEDs
0, 0, 0, 1, 0, // Row 2: 5 LEDs
0, 0, 0, 0, 1, 0, // Row 3: 6 LEDs
0, 1, 1, 1, 1, 1, 0, // Row 4: 7 LEDs
0, 0, 0, 0, 1, 0, // Row 5: 6 LEDs
0, 0, 0, 1, 0, // Row 6: 5 LEDs
0, 0, 0, 0 // Row 7: 4 LEDs
};

for (int i = 0; i < NUM_LEDS; i++) {
if (arrowPattern[i] == 1) {
leds[i] = CRGB::Red; // Set LED to red
} else {
leds[i] = CRGB::Blac
k; // Turn off LED
}
}

FastLED.show();
delay(500); // Keep the arrow displayed
}

Results

It worked, a red arrow.

Upgrade

Pattern

Look at this part in the code:
void loop() {
// Define the arrow pattern for your custom layout
int arrowPattern[37] = {
0, 0, 0, 0, // Row 1: 4 LEDs
0, 0, 0, 1, 0, // Row 2: 5 LEDs
0, 0, 0, 0, 1, 0, // Row 3: 6 LEDs
0, 1, 1, 1, 1, 1, 0, // Row 4: 7 LEDs
0, 0, 0, 0, 1, 0, // Row 5: 6 LEDs
0, 0, 0, 1, 0, // Row 6: 5 LEDs
0, 0, 0, 0 // Row 7: 4 LEDs
};
Replace 0 with 1 to make your own patten

Color

Look at this part:

for (int i = 0; i < NUM_LEDS; i++) {
if (arrowPattern[i] == 1) {
leds[i] = CRGB::Red; // Set LED to red
} else {
leds[i] = CRGB::Black; // Turn off LED
}
}

Change your favorite color
If you want RGB color, use this code:

for (int i = 0; i < NUM_LEDS; i++) {
if (arrowPattern[i] == 1) {
leds[i] = CHSV((millis() / 10) + (i * 10), 255, brightness); // RGB color based on time
} else {
leds[i] = CRGB::Black; // Turn off LED
}
}

It looks like this:

So much fun, get your own NeoHEX right now, hurry up!
Subscribe to our newsletter for the latest updates on cutting-edge AIoT solutions and exclusive product discounts!
Follow us on X / LinkedIn to stay connected for upcoming meetups and cutting-edge IoT projects!
Join our WhatsApp AIoT Hero Community to network with AIoT professionals and share your innovative ideas!

 

Leave a comment

Your email address will not be published. Required fields are marked *

Sidebar

Blog Categories

This section doesn’t currently include any content. Add content to this section using the sidebar.

Latest post

This section doesn’t currently include any content. Add content to this section using the sidebar.

Registrieren Sie sich für unseren Newsletter

Erhalten Sie die neuesten Informationen über unsere Produkte und Sonderangebote.