int duration; void setup() { pinMode(3, INPUT); pinMode(4, OUTPUT); } void loop() { duration = pulseIn(3, HIGH); digitalWrite(4, LOW); if (duration < 1300) { digitalWrite(4, HIGH); } }