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).
This commit is contained in:
Gregg 2021-10-03 21:39:23 -05:00
parent 7980273609
commit ae1037946a
1 changed files with 1 additions and 0 deletions

View File

@ -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