平成30年度公開講座で演習する内容です。
ESP32を使いリング状にフルカラーLEDが配置されたモジュールの点灯制御を行います。各LEDのチップ内にはWS2812BというICが実装されていて,LEDを数珠つなぎに接続でき,各LEDを任意の色で光らせることができます。このタイプのLEDにはいくつか種類がありますが,FastLEDというライブラリを使えばほとんどのLEDに対応できます。ESP32は,FastLED3.1以上で対応しています。
- gitハブから最新のFastLEDライブラリをダウンロード
GitHub - FastLED/FastLED: The FastLED library for colored LED animation on Arduino. Please direct questions/requests for help to the FastLED Reddit community: http://fastled.io/r We'd like to use github "issues" just for tracking library bugs / enhancements.
The FastLED library for colored LED animation on Arduino. Please direct questions/requests for help to the FastLED Reddit community: We'd like to use gi...
Clone download -> Download ZIP
2. Docuemtns\Arduino\libraries以下に展開
3. サンプルコードを実行
#include <FastLED.h>
const int DATA_PIN = 19;
const int NUM_LEDS = 16;
CRGB leds[NUM_LEDS];
#define FPS 30
void setup() {
// シリアルポートの設定
Serial.begin(115200);
delay(100);
// FastLEDの設定
FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(64);
set_max_power_in_volts_and_milliamps(5, 100);
}
void loop() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(i * 10, 255, 255);
}
FastLED.show();
FastLED.delay(1000 / FPS);
}
4. リングLEDが色相順に光る (写真は試作基板です。)



コメント