## Introduction: Safety Sensor

Influences: My group had no idea what to do so we asked Jean for some ideas. We talked a lot and finally got an idea. A very common problem in school are the thefts on other person lockers.

Idea: The idea is to have a way to prevent your locker with something that isn´t a lock. The Arduino is cheaper than a lock. The educational agents will hear a loud noise if someone tries to open another person locker.

## Step 1: Influences:

My group had no idea what to do so we asked Jean for some ideas. We talked a lot and finally got an idea. A very common problem in school are the thefts on other person lockers. My group decided to do a very safe locker to prevent thefts in school.

## Step 2: Coding

```/** Ultrasonic Sensor HC-SR04 and Arduino Tutorial
*
* by Dejan Nedelkovski,
* www.HowToMechatronics.com
*
*/
// defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
const int buzzPin = 2;
const int button1 = 3;
int making =0;
// defines variables
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(buzzPin, OUTPUT);
pinMode (button1, INPUT);
Serial.begin(9600); // Starts the serial communication
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
Serial.println(making);if(distance>35){
digitalWrite(buzzPin, HIGH);
if (making == HIGH) {
digitalWrite(buzzPin, LOW);
delay(10000);
}
} else {
digitalWrite(buzzPin, LOW);
}
}```

## Step 3: How It Works

First, you need to open the door when you approximate your hand to more than 20 centimeters, the system will start to make a noise. To stop the noise there is a hidden button that can stop with the noise. The noise function is to alarm the educationals agents that there is somebody on someone's locker.