#define pow 0
#define echo 1
#define trig 2
#define LED 3
void setup() {
// put your setup code here, to run once:
pinMode(pow, OUTPUT);
pinMode(echo, INPUT);
pinMode(trig, OUTPUT);
pinMode(LED, OUTPUT);
digitalWrite(pow, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
// Read the result:
int duration = pulseIn(echo, HIGH);
if(duration/50 < 100){
digitalWrite(LED, HIGH);
}
delay(1000);
digitalWrite(LED, LOW);
}