Maker 101
Published © GPL3+

How to Make a Talking PIR Motion Security System

In this project we will make a security system that detects motion and speaks.

BeginnerFull instructions provided1 hour2,849
How to Make a Talking PIR Motion Security System

Things used in this project

Hardware components

Arduino Nano Board
×1
DFPlayer Mini MP3
×1
Mini PIR Motion Sensor
×1
Mini Speaker
×1
Breadboard 400 Hole
×1
Jumper Wire 3 in 1
×1
1K Ohm Resistor
×1
Micro SD Card
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

PIR-Motion-Security-System

Arduino
Upload the Sound to SD Card
Download the Source Code
Install the Required Hardware
Select the Board and Port
Upload the Code
For more information see the video tutorial.
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

#define SENSORPIN 9
#define PAUSETIME 20000

void setup() {
  mySoftwareSerial.begin(9600);
  Serial.begin(115200);
  pinMode(SENSORPIN, INPUT);

  Serial.println();
  Serial.println(F("Initializing DFPlayer..."));

  //Use softwareSerial to communicate with MP3
  if (!myDFPlayer.begin(mySoftwareSerial)) {
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while(true);
  }
  Serial.println(F("DFPlayer Mini online."));

  //Set volume value (From 0 to 30)
  myDFPlayer.volume(25);
}

void sensorActivated() {
  int pirSensor = digitalRead(SENSORPIN);
  if(pirSensor == HIGH)
  {
    Serial.println("Sensor Activated");
    Serial.println("DFPlayer Working...");
    myDFPlayer.play(1);
  }
  return;
}

void loop() {
  sensorActivated();
  delay(PAUSETIME);
}

Credits

Maker 101

Maker 101

41 projects • 171 followers
Maker 101; Beginner and intermediate level Maker projects!

Comments