Things used in this project

Hardware components:
A000066 iso both
Arduino UNO & Genuino UNO
×1
09590 01
LED (generic)
×4
ultrasonic sensor
×1
11026 02
Jumper wires (generic)
×1
Software apps and online services:
Ide web
Arduino IDE

Code

Arduino codeArduino
int s1=9;
int s2=7;
int s3=10;
int s4=11;
int trig=8;
int echo=12;                 
int vreme,dinstanca;
void setup() {

pinMode(s1,OUTPUT);
pinMode(s2,OUTPUT); 
pinMode(s3,OUTPUT);
pinMode(s4,OUTPUT);  
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
}

void loop() {
digitalWrite(trig,LOW);
delayMicroseconds(2);
digitalWrite(trig,HIGH);
delayMicroseconds(10);
digitalWrite(trig,LOW);
vreme=pulseIn(echo,HIGH);
dinstanca=vreme/2/29;
if(dinstanca<5){
botti();
}
  
}
void botti(){
  
digitalWrite(s1,HIGH);
digitalWrite(s2,LOW);
digitalWrite(s3,HIGH);
digitalWrite(s4,LOW);
delay(5000);   
digitalWrite(s1,LOW);
digitalWrite(s2,HIGH);
digitalWrite(s3,LOW);
digitalWrite(s4,HIGH);

  }

Credits

6098c3738136b594919dce817cdfccbe
Botti
0 projects • 2 followers
Contact
Logokocka lzxtgjyylt
MakerRobotics
6 projects • 75 followers
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog