// https://wokwi.com/projects/428322248636228609
// for https://forum.arduino.cc/t/problems-with-photodiode-ir-receiver/1372146/142?u=davex
void setup() {
pinMode(2, INPUT_PULLUP);
Serial.begin(115200);
Serial.println(F(R"(pulseIn demo -
note that this skips every other pulse
because pulsein(pin,HIGH) matches a full ___/---\___ cycle
and pulsein(pin,LOW) matches a full ---\___/--- cycle
See https://docs.arduino.cc/language-reference/en/functions/advanced-io/pulseIn/ )"));
}
void loop() {
long duration;
duration = pulseIn(2, LOW, 10000000);
Serial.print("LOW:");
Serial.print(duration);
duration = pulseIn(2, HIGH, 10000000);
Serial.print(" HIGH:");
Serial.println(duration);
}