From ae1037946a46fe8bd47f3063f70b1411ba7326a8 Mon Sep 17 00:00:00 2001 From: Gregg Date: Sun, 3 Oct 2021 21:39:23 -0500 Subject: [PATCH] Update Blinker() to fix inherent problem with digitalRead() in ESP32-C3 Pin must be INPUT_OUTPUT for digitalRead to work with ESP32-C3 (the IDF uses a new protocol for the C3). --- src/Utils.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Utils.cpp b/src/Utils.cpp index 9417f75..dbeeaab 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -227,6 +227,7 @@ Blinker::Blinker(int pin, int timerNum){ void Blinker::init(int pin, int timerNum){ this->pin=pin; pinMode(pin,OUTPUT); + gpio_set_direction((gpio_num_t)pin, GPIO_MODE_INPUT_OUTPUT); // needed to ensure digitalRead() functions correctly on ESP32-C3 digitalWrite(pin,0); #if SOC_TIMER_GROUP_TIMERS_PER_GROUP>1 // ESP32 and ESP32-S2 contains two timers per timer group