Hardware: esp-03
Core Version: latest
Hi,
should the digital pin be resettet everytime?
Now when i set it to HIGH (connect it to 3.3v), it stays high until I set it to LOW (ground).
Is it possible to set it to LOW everytime, and only switch to HIGH if 3.3v are connected?
Module: Generic ESP8266 Module
Flash Size: 4MB/1MB
CPU Frequency: 80Mhz
Flash Mode: qio
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: ck
#include <Arduino.h>
void setup() {
Serial.begin(115200);
pinMode(12, INPUT);
}
void loop() {
Serial.println(digitalRead(12));
}
You can add a pull-down resistor (10k, for example) to achieve this.
Thanks for the fast answer. Isn't there one included? (like in the arduinos. eg nano....INPUT_PULLUP?)
Well you can use pinMode(12, INPUT_PULLUP), but that will work other way around — return 1 unless you pull pin low.
What you need is INPUT_PULLDOWN, but ESP8266 doesn't have internal pull-downs on GPIOs, except for GPIO16.