Created
April 4, 2020 01:53
-
-
Save TakuroFukamizu/06cd32e594d8107700d1883bbd3dd8b7 to your computer and use it in GitHub Desktop.
m5atom-simple-click-and-progress-demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "M5Atom.h" | |
uint8_t counter = 0; | |
uint8_t color_index = 0; | |
const CRGB COLOR[4] = { | |
0xf00000, | |
0x00f000, | |
0x0000f0, | |
0x707070 | |
}; | |
void setup() { | |
M5.begin(true, false, true); | |
delay(50); | |
M5.dis.clear(); | |
} | |
void loop() { | |
if (M5.Btn.wasPressed()) { | |
counter++; | |
if (NUM_LEDS <= counter) { // NUM_LEDS は M5Atomライブラリにある | |
counter = 0; | |
color_index++; | |
} | |
if (4 <= color_index) { | |
color_index = 0; | |
} | |
} | |
for (int i=0; i<counter+1; i++) { | |
M5.dis.drawpix(i, COLOR[color_index]); | |
} | |
delay(100); | |
M5.update(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment