Project tutorial
Soda Can Alarm

Soda Can Alarm © GPL3+

Ever lose something because of someone entering your room? if you have, then I will show you how to build a low-cost alarm!

  • 1,744 views
  • 4 comments
  • 6 respects

Components and supplies

Apps and online services

About this project

So the idea for the project started when I wanted to find a solution, in order not to let people come into my room without my permission.

Before I want to use the motion sensor module, and a buzzer to make my own alarm. But recently I have a stock of ultrasonic sensor and an idea come to my mind, why don't I fused this ultrasonic sensor with servo, and used that servo to push soda can fall by putting a long stick above the servo.

What I mean is for a long time people built soda can as one of many tools to built alarm, and I thought why not combine this soda can with modern technology that was available now.

Step 1

Assemble the circuit by using the schematic I give below

Step 2

Find any soda can and stick you can find, I used chopstick if you curious and put the chopstick on the top of the servo. Don't forget to put the soda can in front of the servo, and adjust the x inside the code to your distance need mine is 17 m.

Step 3

Integrate those stick and soda can, and put the alarm in any place you like. Me personally I put near my room door and put it in the top of printer, because it's the closest thing in my room to the door.

Future

I have a few idea to incoporate this alarm in future, like connected it to ESP36 or IFTTT so it can send notification if the alarm trigger. Feel free to add additional module or improvement on my project.

If I left anything important in this guide, feel free to contact me by commenting below.

Code

Soda Can Alarm CodeArduino
Make sure to put the right distance by measuring the distance of your sensor to the target (wall, etc)
#include <Servo.h> //include the servo library

#define trig 6 // we used pin 6 for the trig pin, and pi
#define echo 5   


int x = 17; // (in cm), measure how long the distance between object and ultrasonic sensor 
int distance;  // variable to save the distance you get from getdistance function



Servo myservo;

void setup(){
  pinMode(trig, OUTPUT); // setup trig and echo 
  pinMode(echo, INPUT);
  myservo.attach(9); // attack servo to pin number 9
  Serial.begin(9600);// begin serial monitor
}


void loop(){
    distance = getdistance(); // get the distance from function
    Serial.print("Distance:"); // print Distance 
    Serial.println(distance); // print on the same line as distance
                              // it put the value of the distance in cm
  
   if(distance <= x){          // if distance less than equal to x
      myservo.write(180); // turn servo 180 degree
      delay(1000);        // delay 1 second
      myservo.write(0);   // turn servo back to it's original position
      delay(1000);        // delay 1 second
    }
    else if(distance >= x){  // if distance more than equal to x
                          // do nothing
    }
    delay(50); // delay loops for 50 second
}
    

float getdistance(){ // function to get distance from sensor

  unsigned long duration; 
  float calculatedDistance; // add duration and calculatedDistance as variable
 
  digitalWrite(trig, LOW); // send signal to object
  delayMicroseconds(10);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);


  duration = pulseIn(echo, HIGH); // receive the signal
  calculatedDistance = duration*0.034/2;
  // from send to receive signal we get the time and 
  // put the equation s = v*t (v= 0.034 the speed of sound)
  // divided by two in order to get the real distance 
  return calculatedDistance; // return the distance to loop
  
}

Schematics

The Schematic
Soda can alarm bb ln6aryeygz

Comments

Similar projects you might like

Buzzer Alarm System With Help Of Arduino

by Team ONYX

  • 37,878 views
  • 5 comments
  • 21 respects

Door Alarm With Ultrasonic Sensor

Project showcase by MattG

  • 4,893 views
  • 1 comment
  • 8 respects

Making Capacitance Alarm with Arduino

Project tutorial by muhammed shameel k.v

  • 860 views
  • 0 comments
  • 1 respect

GSM Home Alarm V1.0

Project tutorial by Hugo Gomes

  • 28,051 views
  • 13 comments
  • 42 respects

Alarm System Security Put to the Test

Project tutorial by danionescu

  • 12,767 views
  • 4 comments
  • 23 respects

Complete Digital Clock Including Alarm and Motion Sensor

Project tutorial by LAGSILVA

  • 12,819 views
  • 11 comments
  • 50 respects
Add projectSign up / Login