@Waiduino

const int echo=13;
const int trig=12;
int LED1=2;
int LED2=3;
int LED3=4;
int LED4=5;

int duration=0;
int distance=0;

void setup() {
  pinMode(trig,OUTPUT);
  pinMode(echo,INPUT);
  pinMode(LED1,OUTPUT);
  pinMode(LED2,OUTPUT);
  pinMode(LED3,OUTPUT);
  pinMode(LED4,OUTPUT);
  Serial.begin(9600);

}

void loop() {

digitalWrite(trig,HIGH);
delay(1000);
digitalWrite(trig,LOW);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
digitalWrite(LED3,LOW);
digitalWrite(LED4,LOW);

duration=pulseIn(echo,HIGH);
distance= (duration/2)/28.5;

if (distance<10){
  digitalWrite(LED1,HIGH);
}
else if (distance>=10 && distance <=20){
  digitalWrite(LED2,HIGH);
}
else if (distance>20&& distance <30){
  digitalWrite(LED3,HIGH);
}
else{
  digitalWrite(LED4,HIGH);
}

Serial.println(distance);
}

@layanshali8015

Hello just wanted to say thanks, I tried this in my class, it was my first time using ultrasonic and it worked💗

@manjuyadav-ws4xd

Yo the channel owner is legend for replying to all comments most YouTubers dont do that

@Dan-eu1dd

wow, that worked flawlessly. Thanks so much.

@lyndalekirk6883

Very well explained thanks

@ShreyashTiwari007

Thank you that helped me alot in my science exhibition project

@deepeshsuragi6229

Thanks very well explained & you gained one new subscriber

@chidinmaokoli6929

Nice video 
It would have been nicer 😢if you would explain why you connect the pins that way like why the pin is connected to 5 volts😢

@Mr.chasmish

You just gained a new subscriber by this video 😊😊

@RixtronixLAB

Creative video, thank you :)

@industrialelectricalbd6900

NICE PROJECT!
 THANKS A LOT SIR

@Sabbir-ln3bx

How do you do it with all the leds on and when you put your hands closer to the leds they turn off one by one?

@turtleburglary1141

Waiduino: audio shift
Me: tears ears off by accident

@mikefranzsalvador6977

One year late, but thank you!<3

@teerthkhiya1208

Hello 
Thank you very much for this video 
I was hoping if you could please mention the name of the all components for this experiment

@PrinceEffah-v7m

Thank you God bless you very very much

@temancubemlangeni925

Thank you so much . Can i see a systematic diagram 😢

@amiraqistina5568

Hi can you list out all the compenants you use? And how to email you for the diagram circuit?

@graemebrumfitt6668

Rite Waiduino Dude,  TFS, GB :)

@DannyYuson

endless thanks