Skip to content

Instantly share code, notes, and snippets.

@paccerdk
paccerdk / debounce.cpp
Created February 19, 2023 01:15
example of debouncing for esp8266/esp32 using arduino framework
//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() {
@paccerdk
paccerdk / i2c example
Last active August 28, 2019 18:10
i2c example
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <Wire.h>
#define LED_BUILTIN 2
void setup()
{
WiFi.mode( WIFI_OFF );
WiFi.forceSleepBegin();