
Arduino Quick Start
M5NanoH2.
Before powering on, press and hold the input button on the front of M5NanoH2, then connect the USB cable to supply power to enter download mode.
Connect the device to the computer via USB cable, then select the corresponding device port in the Arduino IDE.
Enter the following code in the Arduino IDE workspace and click the upload button. The program will be compiled and flashed automatically.
ENABLE_PIN in the code below must be driven to a HIGH level.#include <Adafruit_NeoPixel.h>
#define RGB_LED_PIN 11
#define ENABLE_PIN 10
#define NUM_LEDS 1
Adafruit_NeoPixel strip(NUM_LEDS, RGB_LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pinMode(ENABLE_PIN, OUTPUT);
digitalWrite(ENABLE_PIN, HIGH);
strip.begin();
strip.show();
}
void loop() {
//RED
strip.setPixelColor(0, strip.Color(255, 0, 0));
strip.show();
delay(100);
//GREEN
strip.setPixelColor(0, strip.Color(0, 255, 0));
strip.show();
delay(100);
//BLUE
strip.setPixelColor(0, strip.Color(0, 0, 255));
strip.show();
delay(100);
}
After uploading the code, the RGB LED on the M5NanoH2 device will cycle through red, green, and blue. Once flashing is complete, please disconnect the device and power it on again for normal operation.