Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: UIT_WS2812B mbed
Diff: main.cpp
- Revision:
- 3:221db7d7ad6b
- Parent:
- 2:dd3a46973368
- Child:
- 4:3e09f47b3c42
--- a/main.cpp Sun Sep 25 10:01:28 2016 +0000 +++ b/main.cpp Mon Sep 26 02:06:16 2016 +0000 @@ -1,7 +1,7 @@ //---------------------------------------------------- // WS2812B クラスの使用例 // -// 2016/09/25, Copyright (c) 2016 MIKAMI, Naoki +// 2016/09/26, Copyright (c) 2016 MIKAMI, Naoki //---------------------------------------------------- #include "mbed.h" @@ -20,14 +20,28 @@ myLed_.Clear(8); wait(0.5f); myLed_.Write(0x0F0F0F); // G + R + B,強度小 - myLed_.Write(0xFF0000); // G + myLed_.Write(0xFF0000); // G myLed_.Write(0x00FF00); // R myLed_.Write(0x0000FF); // B myLed_.Write(0x00FFFF); // R + B myLed_.Write(0xFFFF00); // G + R myLed_.Write(0xFF00FF); // G + B myLed_.Write(0xFFFFFF); // G + R + B - myLed_.Reset(); + wait(0.5f); + + // 全部を R + B に + myLed_.Write(0x00FFFF, 8); // R + B + wait(0.5f); - while (true) {} + // 点灯色を順に変化させる + uint32_t data[] = { 0x0F0F0F, 0xFF0000, 0x00FF00, 0x0000FF, + 0x00FFFF, 0xFFFF00, 0xFF00FF, 0xFFFFFF}; + int k = 0; + while (true) + { + for (int n=0; n<8; n++) + myLed_.Write(data[(k+n) & 0x7]); + k = ++k & 0x07; + wait(0.5f); + } }