Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
You are viewing an older revision! See the latest version
Button Klasse
mbedESP32_blueLeds-Button-Class.ino
#define LED1 19 // GPIO19 #define CENTER 25 // GPIO25 struct Button { // oder struct public: const uint8_t PIN; uint32_t numberKeyPresses; bool pressed; }; Button button1 = {CENTER, 0, false}; void IRAM_ATTR isr() { digitalWrite(LED1, !digitalRead(LED1)); button1.numberKeyPresses += 1; button1.pressed = true; } void setup() { Serial.begin(115200); pinMode(LED1, OUTPUT); pinMode(button1.PIN, INPUT_PULLDOWN); attachInterrupt(button1.PIN, isr, FALLING); } void loop() { if (button1.pressed) { Serial.printf("Button 1 has been pressed %u times\n", button1.numberKeyPresses); button1.pressed = false; } }