Adrian Perez
Published © MIT

LoveBox

Great anniversary/Valentine's Day gift. Music Box that plays favorite song with screen displaying picture.

BeginnerWork in progress10 hours1,154
LoveBox

Things used in this project

Hardware components

Adafruit NeoPixel LED Strip 60/m
×1
MIKROE OLED C Click
×1
Adafruit Mini External USB Stereo Speaker 3369
×1
PocketBeagle
BeagleBoard.org PocketBeagle
×1
Male/Male Jumper Wires
×1
SparkFun microB USB Breakout
SparkFun microB USB Breakout
×1
Adafruit USB Micro to USB (Tiny OTG Adapter)
×1

Story

Read more

Custom parts and enclosures

Heart Box Laser Cut File

Illustrator File to be used on software for laser cutting. See instructables link more more information on the file.

Code

Play

Python
Image choices: Place images in folder where program is located. Program will randomly select one to display.
Song: Plays mp3 file located in folder where program is located.
"""
--------------------------------------------------------------------------
LoveBox Project
--------------------------------------------------------------------------
License: MIT
Copyright 2018 Adrian Perez

Redistribution and use in source and binary forms, with or without 
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this 
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, 
this list of conditions and the following disclaimer in the documentation 
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors 
may be used to endorse or promote products derived from this software without 
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------

"""
import time
import random
import os

def pics():
    image_choices = ['0.jpg', '1.jpg','2.jpg','3.jpg','4.jpg','5.jpg']
    choice = random.randint(0,4)
    command = 'sudo /var/lib/cloud9/ENGI301/Project/display.sh ' + image_choices[choice]
    print(choice)
    print(command)
    os.system(command)
    time.sleep(.2)
    
def song():
    time.sleep(.1)
    os.system('/var/lib/cloud9/ENGI301/Project/Play.sh ')
    
pics()
song()

Music

Python
Must download mplayer and alsaaudio. Ensure playback device is selected in microcontroller. Default volume set to 20, not recommended for volume to be any higher than that.
#!/bin/bash
mplayer -volume 20  rose.mp3

Display

Python
Uses frame buffer image viewer to display images.
#!/bin/bash
sudo fbi -T 1 $1

Credits

Adrian Perez

Adrian Perez

1 project • 0 followers

Comments