@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

@Mr.chasmish

You just gained a new subscriber by this video 😊😊

@lyndalekirk6883

Very well explained thanks

@deepeshsuragi6229

Thanks very well explained & you gained one new subscriber

@ShreyashTiwari007

Thank you that helped me alot in my science exhibition project

@RixtronixLAB

Creative video, thank you :)

@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😢

@amiraqistina5568

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

@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?

@paulcarsco6029

I tried using the code but it didn't work because I need a value for  the pulseln variable?

@jesussaquin6266

at 6:12 idk if my wiring is right but my LED is not lighting up

@apicc9270

Can you please help me? I used a code our teacher provided but for some reason the LCD and the sensor are not working. it lights up but there's no display. LED is constantly turned on

@turtleburglary1141

Waiduino: audio shift
Me: tears ears off by accident

@geoffreyaduda

What are the components required to be used in smart home lighting control system using Arduino (audio controlled)

@LayalAman

Can u help me please there is an error message saying pulseln was not declared in this scope

@graemebrumfitt6668

Rite Waiduino Dude,  TFS, GB :)

@nezu_chan1993

i uploaded it but when i tried to check the seriel monitor it wasn't showing anything ;(