Arduino 上手教程
M5NanoC6
。将设备通过USB线连接至电脑,在Arduino IDE中可选中对应设备的端口。
在Arduino IDE 工作区输入下方代码, 点击上传按钮,将自动进行程序编译与烧录。
ENABLE_PIN
。#include <Adafruit_NeoPixel.h>
#define LED_PIN 20
#define ENABLE_PIN 19
#define NUM_LEDS 1
Adafruit_NeoPixel strip(NUM_LEDS, 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);
}
上传代码后即可看到 M5NanoC6 设备上的RGB LED灯循环亮起红绿蓝三色。