Project 1.1 - Motion Sensor Alarm

Introduction: Project 1.1 - Motion Sensor Alarm

In this exercise we will create a motion sensor that will trigger an alarm.

To begin this lab you will need:

1 Arduino Micro-controller

1 Breadboard

8 Copper Wires

1 Passive Buzzer

1 Ultrasonic Sensor

Step 1: Connect the Sensor

At this point you should have all of your parts ready. Begin by connecting the ground rail to the GND on your Arduino. Next up, connect a wire to the power rail from your 5V pin on the Arduino. From here, connect the ground rail to the GND on your sensor, connect the power rail to the VCC, connect echo to pin 12, and lastly connect trig to pin 10.

Step 2: Connect the Buzzer

At this point you should have your ultrasonic sensor connected properly. It is now time to add our buzzer. Place the buzzer into the breadboard. Connect the (+) side of the buzzer to pin 8, and connect the other side to the ground rail.

Step 3: Testing Your Project

Now you have both a device capable of reading distance inputs and one capable of producing sound. Using the attached source code any variation in distance will trigger a tone to be played, based off distance.

Be the First to Share

    Recommendations

    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    2 Discussions

    0
    munishdhingra77
    munishdhingra77

    Question 1 year ago

    To trigger relay at specific time, I have written digitalWrite(RELAY, LOW) But relay remains on all the time.

    Can some one help me please. I have written the code as follows:

    #include
    #include // Library for RTC Module
    int Relay = 4; // Assigned Pin for Relay Module
    /* it is a constructor and it creates an Object of type DS3231 called rtc using the two pins defined somewhere else as SDA and SCL */
    DS3231 rtc(SDA, SCL);
    Time t;
    /* Parameters which are used to call time in the code to turn relay on and off. */
    const int OnHour = 17;
    const int OnMin = 40;
    const int OffHour = 17;
    const int OffMin = 41;
    /* The setup() function is called when a sketch starts. It is used to initialize variables, pin modes, start using libraries, etc. This function will only run once, after each power up or reset of the Arduino board. */
    void setup()
    {
    Serial.begin(9600); // Baud Rate
    rtc.begin();
    pinMode(Relay, OUTPUT); // Relay acts as Output
    digitalWrite(Relay, LOW); // Pin 4 is Low
    }
    /* This Particular Function is used for Repeated Execution of the Circuit until Specified. */
    void loop()
    {
    t = rtc.getTime(); // get values of Time
    Serial.print(t.hour); // Print the values
    Serial.print(" hour(s), "); // Print the message with values
    Serial.print(t.min); // Print the values
    Serial.print(" minute(s)"); // Print the message with values
    Serial.println(" ");
    delay (1000); // Hold By 1000 ms
    if (t.hour == OnHour && t.min == OnMin) // When the values are equivalent
    {
    digitalWrite(Relay, HIGH); // Pin 4 is HIGH
    Serial.println("LIGHT ON"); // Print the Message
    }
    else if (t.hour == OffHour && t.min == OffMin) // When the values are equivalent
    {
    digitalWrite(Relay, LOW); // Pin 4 is Low
    Serial.println("LIGHT OFF"); // Print the Message
    }
    }

    0
    munishdhingra77
    munishdhingra77

    Question 1 year ago on Introduction

    Hi,
    While compiling I recieved the following error message:
    Can you please help solving this problem.
    Regards
    Munish Dhingra


    Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno"
    MotionAlarm:1:10: error: NewTone.h: No such file or directory
    #include
    ^~~~~~~~~~~
    compilation terminated.
    exit status 1
    NewTone.h: No such file or directory
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.