Edge Sensor

by tikatikatika in Circuits > Arduino

220 Views, 0 Favorites, 0 Comments

Edge Sensor

WIN_20181126_08_07_33_Pro.jpg

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

the Code

captura maker instructables.PNG

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);
 }

The Physical Part

WIN_20181105_08_53_29_Pro.jpg
WIN_20181126_08_32_05_Pro.jpg

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

Assemble

WIN_20181105_08_55_55_Pro.jpg

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