In this tutorial, we will create a DIY home automation system that plays a personalized welcome audio whenever motion is detected. You’ll learn how to integrate motion sensors with audio playback devices to create a unique and interactive experience for your visitors. We’ll guide you through the step-by-step process of setting up the motion detection system, configuring the audio playback, and customizing the welcome message. Join us and add a touch of creativity and automation to your home! You can make this project with little effort after watching this video.
For making this project, I am using:-
1. Arduino Nano…. https://s.click.aliexpress.com/e/_Dd89I6J
2. Df player mini…. https://s.click.aliexpress.com/e/_DEc2Cwr
3. PIR Sensor……… https://s.click.aliexpress.com/e/_DCeVuQr
4. Speaker…………. https://s.click.aliexpress.com/e/_DeHoKPt
5. Jumper Wires… https://s.click.aliexpress.com/e/_DF0yEAR
6. 1k Resistor……. https://s.click.aliexpress.com/e/_DFOihPN
7. Bread Board…. https://s.click.aliexpress.com/e/_DBzqbQL
Code:-
#include “SoftwareSerial.h”
#include “DFRobotDFPlayerMini.h”
// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 2; // Connects to module’s RX
static const uint8_t PIN_MP3_RX = 3; // Connects to module’s TX
SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);
const int PIR = 7;
int input_val = 0;
// Create the Player object
DFRobotDFPlayerMini player;
void setup() {
// Init USB serial port for debugging
Serial.begin(9600);
// Init serial port for DFPlayer Mini
softwareSerial.begin(9600);
// Start communication with DFPlayer Mini
if (player.begin(softwareSerial)) {
Serial.println(“OK”);
// Set volume to maximum (0 to 30).
player.volume(30);
} else {
Serial.println(“Connecting to DFPlayer Mini failed!”);
}
delay(50000);
}
void loop() {
input_val = digitalRead(PIR);
delay(1000);
Serial.println(input_val);
if (input_val > 0)
{
player.play(1);
Serial.println(“motion detected “);
delay(10000);
}
}
Library for DF Player mini:- https://github.com/DFRobot/DFPlayer-Mini-mp3
More Projects
How to Play Different Audios Using a Keypad
How to Play Different Audios Using a Keypad and Arduino
DFPlayer Mini Interface with ESP32
Audio Playback Tutorial | Add voice to ESP32
Df Player interface with Arduino
How to play Audio by using Arduino and DF player mini.