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.

img_9988
Hall Effect Sensor and MP3 Player Code

#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);
}
}

Testing Hall Effect Sensor Code

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”);
}
}

Testing MP3 Player Code

#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);

}

First Milestone

I completed the electrical part of my project. First, I made the circuit on a breadboard which included a hall effect sensor and a push button. The hall effect sensor in my project senses the presence of a magnetic field––when a magnet is brought close to it––and changes the output voltage which triggers an mp3 file on the mp3 player shield. The push button serves as an emergency stop button and immediately stops the music when it’s pushed. After following a sample code from arduino to test both the hall effect sensor and the push button, I moved the circuit onto the proto shield that I made by soldering female header pins on a stripboard and soldered the circuit on that shield. I then tested the hall effect sensor and the push button through the proto shield to make sure I soldered all the wires and resistors correctly. A challenge I encountered when completing this milestone was that the soldering took lots of time and making the bridges between the holes on the proto shield was frustrating as I would make a bridge and then accidentally break it and have to solder it again. This challenge lasted throughout most of the soldering, but in the end, the hall effect sensor and the push button both worked which demonstrated that although it took a while, I soldered effectively and correctly. I liked soldering, even though it took a while, and felt a sense of accomplishment when the push button and the hall effect sensor worked.

hall-sensor-schematic
img_0005

Starter Project

The Rainbow Light Show is a motion controlled light show that displays many different colors across a strip when it senses movement over a sensor. I built it by soldering sensors, resistors, capacitors and a microcontroller to a PCB and then constructed the cover using screws. Three of those parts were infrared light proximity sensors that consist of two parts. One part is an infrared LED that shines an invisible IR (infrared) light beam upwards, and the second part is a phototransistor that allows current to pass through when exposed to IR light. When a person’s hand moves over the sensor, IR light is reflected back into the phototransistor allowing current to flow through. Additionally, when a person’s hand is moved closer to the sensor, the amount of IR light reflected into the phototransistor increases causing an increase in the amount of current flowing through the light strip which makes the lights shine brighter. Each sensor shines a different color and allows different amounts of current to flow so the microprocessor reads a variable voltage produced due to the changing amount of current for each sensor and uses the varying voltages to decide how bright the red, blue and green channels of each LED should light up. The resistors on the PCB are used to control the current flow so that components don’t get damaged and the capacitors store the electrical energy and release it when the energy is needed to turn on the lights. The last part I used was the microcontroller which is essentially the brain of the circuit and tells the components what to do. When I finished soldering all the parts, I connected the completed PCB and its cover to a light strip. A challenge I faced was that I put a part in the wrong way and had to desolder it from the PCB. It took me a while to fully desolder it and couldn’t figure out exactly how to do it until trying both methods of desoldering––a solder wick and a solder pump. Overall, I liked being able to solve my own problem and fully build this project on my own which included elements of both mechanical and electrical engineering.

Leave a Comment

Start typing and press Enter to search

Bluestamp Engineering