-->
Page 1 of 1

pulseIn problem

PostPosted: Sat Mar 10, 2018 1:00 pm
by alkor_r37
Hello.. I'm trying read a pulse on D0 pin with pulseIn function.. Unfortunately, it gives me zero.. I have done some research and found that this function works only with D3, D4 pins.. Is it possible to work with other pins ?(

Code: Select all#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);
}

Re: pulseIn problem

PostPosted: Mon Mar 12, 2018 4:33 am
by btidey
Can you post link to that research?

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.