Hi all,
recently I bought a new ESP32 cause I hoped that it will be suitable for my robot car project. But when I tried to read my encoder's signal then it responded on both edges.
I am very disappointed, because it is working on ESP8266 but with 32 it's not.
Here is my code where I only use one button:
#include <Arduino.h>
void blink();
byte ledPin = 2;
/* pin that is attached to interrupt */
byte interruptPin = 12;
/* hold the state of LED when toggling */
volatile byte state = LOW;
void setup() {
pinMode(ledPin, OUTPUT);
/* set the interrupt pin as input pulldown*/
pinMode(interruptPin, INPUT_PULLDOWN);
/* attach interrupt to the pin*/
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, RISING);
}
void loop() {
}
/* interrupt function toggle the LED */
void blink() {
state = !state;
digitalWrite(ledPin, state);
}
It is a very simple code, I just wanted to test the interrupts.
I hope anyone can help me to solve my problem.
Thank you in advance!