FinderElectric
Published © GPL3+

Build a "Go Away!" Robot - Easy Starter Project for Kids

Somebody trying to steal your stuff? Make a simple robot that will detect when they get too close and make a loud noise to scare them off!

BeginnerFull instructions provided6,208
Build a "Go Away!" Robot - Easy Starter Project for Kids

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Buzzer, Piezo
Buzzer, Piezo
×1
5 mm LED: Green
5 mm LED: Green
×1

Story

Read more

Schematics

"Go Away!" Robot Diagram

A sketch, breadboard view of our set up for the Arduino and components.

Code

Buzzer and LED Activated by Distance Sensor

Arduino
Distance is in centimeters.
#define trigPin 13
#define echoPin 12
#define buzzer 9 //buzzer to arduino pin 9
#define led 11



void setup()
{ Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
  pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
  pinMode(led, OUTPUT);
}

void loop()
{ long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;

 if (distance < 100)

{ tone(buzzer, 98); // Send 1KHz sound signal...
digitalWrite(led,HIGH);
}

else {
noTone(buzzer);
digitalWrite(led,LOW);
}

Serial.print(distance);
Serial.println(" cm");
delay(500);
}

Credits

FinderElectric
1 project • 3 followers
Contact

Comments

Please log in or sign up to comment.