PIR activated noise making Arduino controlled Stuffed Rabbit :: Student Project
What better way to use your programming and electronics skills than to help out your grandkids? Especially if it involves PIR sensors, an Arduino Nano, and fart noises?
You heard me right, Ken Deakman, a customer of Programming Electronics Academy since late 2018, wanted to enhance a stuffed rabbit with some sensors so that it could respond to motion and alert his granddaughter of any monsters under the bed.
Why the heck did you build a Arduino controlled stuffed rabbit?
I have a 4 year old granddaughter. She is concerned about monsters under the bed. The bunny notifies her when it detects movement…and it’s funny to a 4 year old because it farts..after a delay.
It will soon sound if its altitude changes as when a friend/parent picks it up. Very funny in a 4 year old sort of way. [Editor’s note: My 10 year old and I were also laughing.]
How does your project work?
The Arduino checks the PIR (HIGH or LOW).
- Low – do nothing.
- HIGH – power the sound source.
I have added delays to avoid continuous noise and to suggest randomness.
What was your biggest struggle as you worked through this project?
Still not able to combine barometric pressure reading. My goal is to set a specific “altitude number”.
If the number doesn’t change, continue with the PIR system and it’s alert noise.
If the altitude number changes vs the set number, it’ll disconnect the PIR sound and activate the altitude generated sound. Not there quite yet.
Did the project end up as you expected?
So far…except some random power seems to occasionally power the sound.
Also, I’m still learning how to power Nanos and Arduino Uno with batteries: 9 V battery for example against a 3V system.
Looking back on this project, what can you say you have learned about programming and/or electronics through the creation process?
Mapping out the project on paper versus keeping it in my head would have saved considerable time. Also, I would have saved trouble discovering that most/all my challenges can be solved usually in Arduino enthusiast forums.
Was the training at Programming Electronics Academy able to help you build your skill?
So far so good. Learned right off I should have mapped out the project.
What type of Arduino board, Arduino clone, or Arduino compatible board does your project use?
Arduino Nano
What components did you project use?
Speaker, Resistor, LED, Enclosure, PIR sensor for motion sensing
How do you power your project?
Batteries
Arduino Code:
[Editor’s Note: This was the code Ken submitted, I am assuming he has added some code to activate the audio signal.]
/* * PIR sensor tester */ int ledPin = 6; // choose the pin for the LED int inputPin = 2; // choose the input pin (for PIR sensor) int pirState = LOW; // we start, assuming no motion detected int val = 0; // variable for reading the pin status void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare sensor as input Serial.begin(9600); } void loop(){ val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, HIGH); // turn LED ON delay (600); if (pirState == LOW) { // we have just turned on Serial.println("Motion detected!"); // We only want to print on the output change, not state pirState = HIGH; } } else { digitalWrite(ledPin, LOW); // turn LED OFF if (pirState == HIGH){ // we have just turned off delay (1000); Serial.println("Motion ended!"); // We only want to print on the output change, not state pirState = LOW; } } }
About Ken:
Ken works in education, and has been into electronics for about a year.
When asked how long he has been programming he says – “I program like I golf..swing and keep up with others.” Part of his motivation for submitting this project was his desire to generate a contribution to FIRSTinspires.org (PEA donates money to FIRST when customers submit projects they are working on and the project gets featured on our website).