
Arduino 上手教程
M5NanoH2。
上电前按住 M5NanoH2 正面的输入按键,然后连接 USB 线供电将进入下载模式。
将设备通过 USB 线连接至电脑,在 Arduino IDE 中可选中对应设备的端口。
在 Arduino IDE 工作区输入下方代码,点击上传按钮,将自动进行程序编译与烧录。
ENABLE_PIN 。#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);
}
上传代码后,M5NanoH2 设备上的 RGB LED 灯便会循环显示红、绿、蓝三色。烧录完成后,请拔下设备,重新上电以正常运行。