const int PinEN = 9; const int PinOUT = 6; int enabled = 0; //sensor detection flag void setup() { Serial.begin(9600); enable(); } void loop() { Serial.print(pulseIn(6, HIGH)); // measure the pulse, print the result delay(100); // wait a bit before doing it again } void enable() { pinMode(PinOUT, INPUT); pinMode(PinEN, OUTPUT); digitalWrite(PinEN, HIGH); }