Motion Activated Music Player
The Motion Activated Music Player starts playing music when a door is opened. A magnet is attached to the door, which, when opened, exposes a magnetic field to a hall effect sensor, attached to the wall, and triggers an mp3 file to play music through the speakers.
Engineer
Aliza Meller
Area of Interest
Electrical Engineering and Mechanical Engineering
School
SAR High School
Grade
Incoming Senior
Final Milestone
Reflection
Before attending Bluestamp Engineering, I had minimal experience with Arduino and almost no understanding of the worlds of mechanical and electrical engineering. Bluestamp Engineering has sparked my interest in these two areas so much so that I plan on pursing mechanical and electrical engineering professionally as I delve deeper into the intricacies of engineering in college. This program has helped me learn more about my interests and capabilities and I hope to continue my personal journey on my path to becoming an engineer.
I completed my final milestone for the motion activated music player! Instead of assembling my project to an actual door, I created a miniature door out of cardboard and attached the magnet as the door handle. When the door is open, the magnet passes by the hall effect sensor and triggers ACDC’s “Highway to Hell” for 18 seconds. I downloaded the song as an MP3 file and named it “track004.mp3”. I was also able to figure out how to make the song stop after 18 seconds by adjusting the volume after the given amount of time. The most challenging part of this milestone was getting the door to stand. I attempted to make a stand using cardboard and tape, but after that failed I used screws and L clamps to construct stands. I also used screws to attach the arduino to the wall next to the door. As this part of the project was more for aesthetic purposes, it was less enjoyable than the other milestones, but helped my project look more presentable and effective for its main purpose.
Second Milestone
I completed the code for my project which connects the hall effect sensor and the mp3 player. In this process, I downloaded the libraries for the mp3 player and put a file on the microSD card and named it “track001.mp3”. I wrote the code for the hall effect sensor and the mp3 player separately, and once those both worked, I combined them into one code that allows for the hall effect sensor to trigger an mp3 file once a magnet passes by it. A challenge I faced when writing this code was that I would constantly run a code, but it wouldn’t work and figuring out the problem seemed impossible. Plus, when I figured out what was wrong, and it still didn’t work, I would have to go back from square one to find the problem. I also kept breaking the header pins that attached the mp3 player shield to the arduino and the proto shield which was extremely difficult to have to redo. However, when I finally fixed all of my problems, I was able to figure out the code that pulled all of my components together into one unit. I also got rid of the push button component because I coded the music player in a way that it stopped after a certain period of time. All in all, I liked this part of my project because of the accomplishing feeling I felt after I finally fixed everything and got my project to work.
#include <SPI.h>
#include <SdFat.h>
#include <SFEMP3Shield.h>
SdFat sd;
SFEMP3Shield MP3player;
volatile byte half_revolutions;
unsigned int rpm;
unsigned long timeold;
void setup() {
Serial.begin(9600);
//start the shield
sd.begin(SD_SEL, SPI_HALF_SPEED);
MP3player.begin();
MP3player.setVolume(0,0);
half_revolutions = 0;
rpm = 0;
timeold = 0;
}
void loop() {
if (!digitalRead(5)) {
Serial.println (“detected”);
//start playing track 1
MP3player.playTrack(1);
delay(750);
}
}
volatile byte half_revolutions;
unsigned int rpm;
unsigned long timeold;
void setup()
{
Serial.begin(9600);
half_revolutions = 0;
rpm = 0;
timeold = 0;
}
void loop()//Measure RPM
{
if (!digitalRead(5)) {
Serial.println (“detected”);
}
}
#include <SPI.h>
#include <SdFat.h>
#include <SFEMP3Shield.h>
SdFat sd;
SFEMP3Shield MP3player;
void setup() {
Serial.begin(9600);
//start the shield
sd.begin(SD_SEL, SPI_HALF_SPEED);
MP3player.begin();
//start playing track 1
MP3player.playTrack(1);
}
void loop() {
Serial.println(“MP3 Player Works!”);
delay(2000);
}