#include <FastLED.h>
#define NUM_LEDS 2
#define DATA_PIN 12
#define timeButton 13
#define startButton 14
bool tButton = false;
bool sButton = false;
CRGB leds[NUM_LEDS];
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S2!");
FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
pinMode (timeButton, INPUT_PULLUP);
pinMode(startButton, INPUT_PULLUP);
}
void loop() {
buttonPress();
if (tButton){
Serial.println("Time");
}
if(sButton){
Serial.println("Start");
}
for (int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
// Turn our current led on to white, then show the leds
leds[whiteLed] = CRGB::White;
// Show the leds (only one of which is set to white, from above)
FastLED.show();
// Wait a little bit
delay(100);
// Turn our current led back to black for the next loop around
leds[whiteLed] = CRGB::Black;
}
}
void buttonPress(){
tButton = digitalRead (timeButton);
sButton = digitalRead(startButton);
}
Loading
esp32-s2-devkitm-1
esp32-s2-devkitm-1