This file contains hidden or 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
//This is how i typically handle button presses, while using a minimal amount of clock cycles / avoiding polling and still keeping it responsive:(note: interrupt callbacks should ideally be as simple as possible, so its better to have the logic outside of it.) | |
#include <Arduino.h> | |
#define GPIO_BUTTON 4 | |
#define GPIO_LED 5 | |
const uint16_t debounceDelay = 100; | |
unsigned long lastButtonPress = 0; | |
bool buttonPressed = false; | |
void IRAM_ATTR buttonInterrupt() { |
This file contains hidden or 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 <Arduino.h> | |
#include <ESP8266WiFi.h> | |
#include <Wire.h> | |
#define LED_BUILTIN 2 | |
void setup() | |
{ | |
WiFi.mode( WIFI_OFF ); | |
WiFi.forceSleepBegin(); |