Things used in this project

Code

FIZZQV0IZ6D1PFF.inoArduino
#define trigPin1 A0
#define echoPin1 A1

#define trigPin2 A2
#define echoPin2 A3

#define trigPin3 A4
#define echoPin3 A5


#define motor1 5
#define motor2 6
#define buzzer 3

void setup()
{
pinMode(trigPin1, OUTPUT);

pinMode(echoPin1, INPUT);

pinMode(trigPin2, OUTPUT);

pinMode(echoPin2, INPUT);

pinMode(trigPin3, OUTPUT);

pinMode(echoPin3, INPUT);


pinMode(motor1, OUTPUT);

pinMode(motor2, OUTPUT);

pinMode(buzzer,OUTPUT);

}

void loop()

{

long duration, distance;

digitalWrite(trigPin1, LOW); 

delayMicroseconds(2); 

digitalWrite(trigPin1, HIGH);

delayMicroseconds(1); 

digitalWrite(trigPin1, LOW);

duration = pulseIn(echoPin1, HIGH);

distance = (duration/2) / 29.1;

if (distance < 45)

{ 

 

digitalWrite(buzzer,HIGH);

} else

{



digitalWrite(buzzer,LOW); 

} delay(50);



digitalWrite(trigPin2, LOW); 

delayMicroseconds(2); 

digitalWrite(trigPin2, HIGH);

delayMicroseconds(1); 

digitalWrite(trigPin2, LOW);

duration = pulseIn(echoPin2, HIGH);

distance = (duration/2) / 29.1;

if (distance < 40)

{ 

digitalWrite(motor1,HIGH);



} else

{

digitalWrite(motor1,LOW);

 

} delay(100);




digitalWrite(trigPin3, LOW); 

delayMicroseconds(2); 

digitalWrite(trigPin3, HIGH);

delayMicroseconds(2); 

digitalWrite(trigPin3, LOW);

duration = pulseIn(echoPin3, HIGH);

distance = (duration/2) / 29.1;

if (distance < 30)

{ 

digitalWrite(motor2,HIGH); 

} else

{

digitalWrite(motor2,LOW);

 

} delay(100);

}

Credits

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

Similar projects you might like

Flightduino 101
Intermediate
  • 112
  • 4

Full instructions

A drone project that uses the Neural Pattern Recognition Module and other aspects of the Curie Module to advantage for creating a cool drone

Arduino 101 BLE App
Intermediate
  • 1,376
  • 18

Work in progress

I want to show you how to make an application and connect it with the Arduino 101 platform for Internet of things applications.

Bluetooth smart home
Intermediate
  • 210
  • 4

Full instructions

A concept showing smart home control and automation with Arduino 101, accompanied by a custom Android application.

Avoid Injuries with Smart Backpack
Intermediate
  • 796
  • 11

Full instructions

Smart Backpack helps you to avoid injuries caused by backpacks by alerting you about improper uses.

FM radio
Intermediate
  • 6,872
  • 32

Full instructions

Build a great sounding FM radio with a cool display using an Arduino Nano and the Sparkfun Si4703 FM tuner breakout

Aquariumatic
Intermediate
  • 1,296
  • 12

Work in progress

Aquarium monitor with automation, Web GUI & IOT. Daisychain units can control multiple tanks all from the one master unit.

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback