たまにやっていつも忘れるのでコピペで試せるようにメモ
PlatformIOの設定
iniファイルはこんな感じ
platformio.ini
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:m5stack-atom]
platform = espressif32
board = m5stack-atom
framework = arduino
lib_deps =
m5stack/M5Atom@^0.1.1
fastled/FastLED@^3.6.0
monitor_speed = 115200
main.cpp
ロジカラブログさんの記事のコードをそのまま使わせてもらいました。コードの解説は本家を参照
main.cpp
#include <M5Atom.h>
CRGB dispColor(uint8_t r, uint8_t g, uint8_t b) {
return (CRGB)((r << 16) | (g << 8) | b);
}
void setup() {
M5.begin(true, false, true);
M5.dis.drawpix(0, dispColor(0, 0, 0));
}
void loop() {
M5.update();
if (M5.Btn.isPressed()) {
M5.dis.drawpix(0, dispColor(0, 0, 255));
} else {
M5.dis.drawpix(0, dispColor(20, 20, 20));
}
delay(100);
}
実行
☑️でコンパイル、→
で書き込みです。