# Edge Sensor

95

## Introduction: Edge Sensor

How many times have you accidentally kicked the wall's edge? Many. I bet that pisses you off a lot. Wouldn't it be good if that didn't happen anymore? Well, those days are over! I am proud to announce the Edge Sensor

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: the Code

The first thing I suggest you do is to download the Arduino software, because that's where I made the code.

Here is the code ( You only need to copy and paste it on Arduino ):

```//Leitura de distância com o sensor HC-SR04<br>#include
<ultrasonic.h>
Ultrasonic ultrassom(8,7); // defines the name of the sensor (ultrasound)
// and where trig is turned on(8) and echo(7)
#define LED  = 11; //LED positive pino11 and negative pinoGND
#define buzzer = 2;//buzzer positive pino2 and negative pinoGND

// This function "setup" runs once the arduino is turned on or reseted
void setup() {
Serial.begin(9600); // Makes the  Serial comunication possible in a rate of 9600 bauds.
pinMode(LED, OUTPUT);
pinMode(buzzer, OUTPUT);
long distance;
}</ultrasonic.h>```
```// function that repeats itself forever when the arduino turns on
void ()
{
distancia = ultrassom.Ranging(CM);// ultrassom.Ranging(CM) returns the distance in
// centimeters(CM) or inches(INC)
Serial.print(distancia); // prints the value of the distance variable
Serial.println("cm");
if (distance =< 20){
digitalWrite(LED, HIGH);
digitalWrite(buzzer, HIGH);
else{
digitalWrite(LED,LOW);
digitalWrite(buzzer, LOW);
}
}
delay(100);
}```

## Step 2: The Physical Part

A very important thing are materials that you are going to use, for that I wrote a list:

- 1 Ultrasonic sensor

- 1 red LED

- 1 buzzer

- 8 Male/Female cables

- 1 Arduino panel

- USB cable that fits the arduino

## Step 3: Assemble

This is going to be based on the code, so if you have any doubts of what you are doing you can always go back and check it out.

Part 1: Ultrasonic sensor

Connect the male part of the cables on pins 7 and 8 on the arduino and then it's female parts on the ultrasonic sensor ( in the 2nd and 3rd pins). The other two are going to be connected to the positive and negative parts of the arduino

Part 2 : LED

Connect the female part of the cables on both positive and negative legs of the LED and then connect the male parts in the arduino ( Repeat this process for the buzzer)

( The long legs of the led, the buzzer

173 14K
211 28K
112 10K