int echopin = 5;
int trigpin =15;
int Time;
int Distance;
void setup()
{ // put your setup code here, to run once:
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);
Serial.begin(9600);
}
void loop()
{// put your main code here, to run repeatedly:
digitalWrite(trigpin, LOW);
digitalWrite(trigpin, HIGH);
digitalWrite(trigpin, LOW);
Time =pulseIn(echopin,HIGH);
Distance= Time * 0.034/2;//formula for Distancetance
Serial.println(Distance);
// if (Distance>30){
// digitalWrite(LED1, LOW);
// }
// else{
// digitalWrite(LED1, HIGH);
// }
}