#define FANGET D2
#define FANSET D1
void setup() {
Serial.begin(115200);
analogWriteFreq(25000);
analogWrite(FANSET, 70);
pinMode(FANGET, INPUT);
}
void loop() {
unsigned int pulse = pulseIn(FANGET, LOW);
Serial.println(pulse);
delay(100);
}
Moderator: igrr
I don't see any reason why the code for pulseIn (core_esp8266_wiring_pulse.c) should be pin specific.
A value of 0 indicates a timeout either waiting for pulse or in the pulse itself. You can set the timeout value yourself in the pulseIn call. I think the default is 1 second which is probably as high as you want to go without risking watchdog resets.