pdf-icon

Arduino入門

2. デバイス&サンプル

NanoC6 RGB LED

M5NanoC6 RGB LED サンプルプログラム。本サンプルはAdafruit NeoPixelライブラリをベースに実装されています。使用前にライブラリマネージャーからAdafruit NeoPixel依存ライブラリをインストールしてください。

サンプルプログラム

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#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() {
//赤色
strip.setPixelColor(0, strip.Color(255, 0, 0));
strip.show();
delay(100);
//绿色
strip.setPixelColor(0, strip.Color(0, 255, 0));
strip.show();
delay(100);
//青色
strip.setPixelColor(0, strip.Color(0, 0, 255));
strip.show();
delay(100);
}
On This Page