ardutronic
Published © CC BY-NC-SA

Super Smart Door Alarm

One of the situations that get on my nerves when I'm in my room is when someone comes to see me and then leaves without closing the door.

BeginnerFull instructions provided2 hours503
Super Smart Door Alarm

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Schematic

Code

Door

Arduino
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX

DFRobotDFPlayerMini myDFPlayer;

char command;
int pausa = 0;
int Reed;

unsigned long aktualnyCzas = 0;
unsigned long zapamietanyCzas = 0;
unsigned long roznicaCzasu = 0;
long randNumber;

void setup()
{
  randomSeed(analogRead(0));

  pinMode(2, INPUT); //Reed

  mySoftwareSerial.begin(9600);
  Serial.begin(115200);

  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini"));
  Serial.println(F("Initializing DFPlayer module ... Wait!"));

  if (!myDFPlayer.begin(mySoftwareSerial))
  {
    Serial.println(F("Not initialized:"));
    Serial.println(F("1. Check the DFPlayer Mini connections"));
    Serial.println(F("2. Insert an SD card"));
    while (true);
  }

  Serial.println();
  Serial.println(F("DFPlayer Mini module initialized!"));


  myDFPlayer.setTimeOut(500);
  myDFPlayer.EQ(0);
}

void loop()
{


  Reed = digitalRead(2);

  if (Reed == LOW)
  {
      randNumber = random(23); //Nr. 0-10
      myDFPlayer.volume(20); // VOL: 66%
      myDFPlayer.play(randNumber);
  }

  if (Reed == HIGH)
  {
    myDFPlayer.stop();
    zapamietanyCzas = aktualnyCzas;
  }
  delay(4000);
  myDFPlayer.stop();
  }

Credits

ardutronic
39 projects • 41 followers
I'm 20 years old student of electronic technical college. I'm passionate about electronics as well as editing movies
Contact

Comments

Please log in or sign up to comment.