//https://audio.online-convert.com/convert-to-wav
#include <Servo.h>
#include <NewPing.h>
int x=0;
int trig = 2 ;
int echo = 3 ;
int max_dis = 200 ;
NewPing sonic (trig , echo , max_dis);
Servo myservo; // create servo object to control a servo
void setup() {
Serial.begin(9600);
myservo.attach(5); // attaches the servo on pin 9 to the servo object
}
void loop() {
int us = sonic.ping();
int dis = us / US_ROUNDTRIP_CM ;
myservo.write(0);Serial.println(x);
if(dis<=50&&x==0){
}
delay(2000);
x=1;
myservo.write(90);Serial.println(x);
if(dis<=50&&x==1){
}
delay(2000);
x=2;
myservo.write(90);Serial.println(x);
if(dis<=50&&x==2){
}
delay(2000);
x=0;
}