PIR voice announcement..


Ive been asked to construct a PIR voice announcement device, to put off potential intruders.. the message would basically inform the intruder that they have been detected..

The device must only work during darkness

PIR triggered, this will start the MP3 message, and switch on amp for speaker for the 60seconds required for the duration of the message.

The Voice (MP3 file) must only play once..

The PIR must be muted for an hour (to stop it annoying legitimate people on site)..

So as far as I can see it the board must take a trig input, generate a sinle shot 60 secs on signal, (to control amp),play the mp3 track, then generate a seperate 60 minuite off signal (which will remove dc from the PIR)..

Ive looked at an mp3 module.. that will take trig input, but wonder if you good people have any thoughts, which module to use etc.

I must stress that I'm being pressured on time for a resolution on this.

many thanks

looking at a battery supply 6-12v

I welcome your ideas.


Something like the wave shield should do thejob.
Have a look at the blink without delay example to see how to handle the timing.

ok, Ive ordered the Arduino Uno, with MP3 sheild from cool components.

I'm looking that the pir will take 3 triggers (i.e can play the MP3 track upto 3 times) then sleep / mute for one hour..

the light module will provide an o/p or enable trig when dark..

Any idea of code.??

I'm scared to death of this, as this is my first Arduino project, and I never even looked at PIC programming.

many thanks for any help


this is my first Arduino project, and I never even looked at PIC programming.

Great. Nothing to unlearn then.

Any idea of code.??

Sure. You'll need a setup() function and a loop() function.

There are a bazillion samples around. The Arduino IDE ships with quite a few. The Playground has even more. Search for PIR. Learn how to get the output from the PIR first. Then, learn how to make the MP3 player do something. Then, learn how to make the MP3 do something when the PIR detects motion. Finally, learn how to ignore input again for an hour.

An "alarm" that makes noise for 60 seconds, and then ignores intruders for 59 minutes might as well be an open door, but that's a different issue.

Thanks for your reply. Im looking at this Make: Projects. And when i get this working.. i will then look at the mp3 side of things .. then add on delays.

Please note that this unit is intended to be outdoors to warn people that they are being watched via cctv.. on transmission sites..

I would appreciate any help with this, especially regarding delays and 3 shots then 60min sleep.. also keen to add the possibility of a two other external triggers

One will switch on a siren mp3 track via a separate input
The other will trigger say track 3 when a loop alarm is broken.


Ok Ive got the pir to work with the UNo, no problem..

Im struggling with the MP3 shield... I want to be able to tsrt track one, if pin 2 high, track 3 if pin 3 high etc, and too ignore each other if one of those inputs is high..

Ive found this from bills site, but cant see how to adjust the sketch.

#include <SPI.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <SFEMP3Shield.h>

SFEMP3Shield MP3player;

void setup() {


//start the shield

//start playing track 1

//do something else now
void loop() {

Serial.println("I'm bored!");


void loop(){
val = digitalRead(BUTTON);

if (val == HIGH) {

//start playing track 1

You should use the "insert code" tags (see the #) to insert your code in your post.
Don't think about it too much just do it, it is quick and easy to try things on the Arduino.

Build the code up a step at a time

  • Get the MP3 to play in a loop over and over.
  • Add in a delay, so you get play, delay, play.
  • Add in the test for the button or PIR triggering

If it does not work figure out what you are doing wrong - the code always does what it is supposed to do :slight_smile:

I like the idea of an "Alien" ending where Rippley has set the ship to self destruct and there is a klaxon lots of CO2 and a warning.

What do you mean "on transmission sites" ?

Broadcast TV and FM radio sites..

I've got an mp3 working

using http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Dev/Arduino/Shields/MP3_Player_Example.pde

It starts instanly.. how can i get it to trigger...Ive tried defing a pin etc... but can't get to be triggered.. sorry to be dumb.


It starts instanly..

Is that because it is in "setup" in the code you posted above?

Im using this code http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Dev/Arduino/Shields/MP3_Player_Example.pde

I'm learning the hard way... I firstly just want track 1 to be controlled via an input trigger pin... and then I can work from there..

Please help, as I have 5 days to get this prototype working

many thanks

David UK

Im using this code

The code you linked to is not the same as the code you posted earlier, but starts to play track number 1 as soon as “loop” executes.
You need to make this conditional upon your PIR being triggered.

How van I stop loop executing and get it to trigger on say pin Ai 1 going hi

Ok i can now trigger it, but it is stuck in a loop, what "else" command can I use to stop it?

I don’t know because I can’t see your code.

I cant paste code hear.. it says its too many charcters.

mptrig.txt (12.7 KB)

void loop(){
val = digitalRead(BUTTON); // read input value and store it
// check whether the input is HIGH (button pressed)
if (val == HIGH) {
} else {


Your program has a lot of setup stuff, plus playMP3 which actually plays the track.
The main loop is above.

What is the problem? It looks like you should press the button, the track will start to play, you release the button.
Next time you press the button it will play again, why do you say it is "stuck" in a loop?

If the track keeps playing over and over then that means val is high, so you need to figure out why.

looks like its floating, nice spotting.. so using a pull down 10k pulldown res.. and 1k via button.. few..

ok now i want to make this a 3 shot then lock out for two hours... any thoughts.... I understand the delay comand...

then another button..

really appreciate your warm response to a newbie :wink:


I'm looking that the pir will take 3 triggers (i.e can play the MP3 track upto 3 times) then sleep / mute for one hour..

You maybe need to think more clearly exactly what you want to do.
For example lets say the PIR is triggered, the MP3 plays then its a day before the PIR is triggered for a second time - do you see where I am coming from.

Anyway sticking with playing the MP3 three times; In the setup, initilise a counter to 0. In the loop each time you play the MP3 increment the counter. When the counter gets to 3 wait for your delay and then zero the counter.

You seem to be under some time pressure but if you have got your MP3 to play and can get your PIR to operate the input you really have this all in the bag, you just need to take your time.

do you have an example of the counter ?

also want to add two more button inputs..

many thanks


To count you just increment a variable.
If you have one button working study what you are doing and repeat.
You must have some programming experience?

At some stage you might want to change your requirement to "play an MP3 at most 3 times in an hour", which is probably closer to what you really want to do than having a gap of an hour after it is played for the third time.