//
// "Basic Push Button Hookup"
// Check dev board, pins, upload speed, etc..
// Button used here is a 2-pins, tactical, push-to-break button
// You can watch the button in action via the serial monitor
#include <FastLED.h>
#define LED_PIN 32
#define BTN_PIN 26
#define COLOR_ORDER GRB
#define CHIPSET WS2811
#define NUM_LEDS 10
#define BRIGHTNESS 50
CRGB leds[NUM_LEDS]; //new array representing the number of leds we've enabled
//bool pressed = false;
void setup() {
delay(3000); // sanity delay
Serial.begin(115200);
pinMode(BTN_PIN, INPUT_PULLUP);
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
// FastLED.setBrightness( BRIGHTNESS );
FastLED.setMaxPowerInVoltsAndMilliamps( 3.3, 500);
}
void loop() {
// digitalWrite(BTN_PIN, HIGH);
if (digitalRead(BTN_PIN) == 0) {
fill_solid(leds, NUM_LEDS, CRGB::Black);
Serial.print(digitalRead(BTN_PIN));
} else {
fill_solid(leds, NUM_LEDS, CRGB::Green);
Serial.print(digitalRead(BTN_PIN));
};
FastLED.show();
delay(100);
}
Loading
esp32-devkit-v1
esp32-devkit-v1