Introduction: Motion Detected Music-Raspberry Pi

Picture of Motion Detected Music-Raspberry Pi

The end result of this project is for someone to walk by the Raspberry pi and have Pandora auto play automatically.

Step 1: Installing Pianobar

Run the following commands in the Lxterminal which can be accessed from the home screen
When copying command make sure their are no spaces after the command
sudo apt-get update
sudo apt-get install pianobar

Create and go into painobar configuration folder
mkdir -p .config/pianobar
cd .config/pianobar 

Create the configuration file
nano config

Paste this into the configuration
# This is an example configuration file for pianobar. You may remove the # from
# lines you need and copy/move this file to ~/.config/pianobar/config
# See manpage for a description of the config keys
#
# User
user = your@user.name
password = password
# or
#password_command = gpg --decrypt ~/password

# Proxy (for those who are not living in the USA)
#control_proxy = http://127.0.0.1:9090/

# Keybindings
act_help = ?
act_songlove = +
act_songban = -
act_stationaddmusic = a
act_stationcreate = c
act_stationdelete = d
act_songexplain = e
act_stationaddbygenre = g
act_songinfo = i
act_addshared = j
act_songmove = m
act_songnext = n
act_songpause = p
act_quit = q
act_stationrename = r
act_stationchange = s
act_songtired = t
act_upcoming = u
act_stationselectquickmix = x
act_voldown = (
act_volup = )

# Misc
#audio_quality = low
#autostart_station = 
#event_command = /home/pi/.config/pianobar/scripts/eventcmd.sh
#fifo = /home/pi/.config/pianobar/ctl
#sort = quickmix_10_name_az
#love_icon = [+]
#ban_icon = [-]
#volume = 0

# Format strings
#format_nowplaying_song = [32m%t[0m by [34m%a[0m on %l[31m%r[0m%@%s
#format_nowplaying_station = Station [35m%n[0m
#format_list_song = %i) %a - %t%r

# high-quality audio (192k mp3, for Pandora One subscribers only!)
#audio_quality = high
#rpc_host = internal-tuner.pandora.com
#partner_user = pandora one
#partner_password = TVCKIBGS9AO9TSYLNNFUML0743LH82D
#device = D01
#encrypt_password = 2%3WCL*JU$MP]4
#decrypt_password = U#IO$RZPAB%VX2
tls_fingerprint = 2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0

The login credentials are at the top of the file
Insert your login credentials
user = YOUR_EMAIL_ADDRESS
password = YOUR_PASSWORD
After you are done editing the file press CTRL O then CTRL M then CTRL X

Type CD to go out of the configuration folder
Run the command pianobar 
To test that it is installed correctly

Step 2: Copy the Configuration to the Root Folder

Make a directory in the root directory for the configuration file to go to
sudo mkdir /root/.config/pianobar

Copy the file
sudo cp .config/pianobar/config /root/.config/pianobar 

Step 3: Edit Pianobar Config to Autoplay a Station

Start Pianobar using the command pianobar
When the station starts take note of the string of numbers beside the name of the station
Hit q to exit pianobar 

Edit the configuration for pianobar to auto play that station
sudo nano /root/.config/pianobar/config
Find the line that says
#autostart_station= 
Remove the #

Then
Paste the number on the right side

autostart_station = Numbergoeshere


Find the line that says
#volume = 0
Remove the #
Set the volume according to your speaker
5 is very quiet I wouldn't set it to loud at first

Again make sure their are not spaces after your lines in the configuration 

After you are done editing the file press CTRL O then CTRL M then CTRL X

Step 4: Wire the PIR Sensor

Picture of Wire the PIR Sensor

Wire according to this GPIO Map
5V goes to the VCC pin on PIR sensor
Ground goes to GND pin on PIR sensor
Out goes to pin GPIO 25 (by number 22)


Step 5: Download the Code

Type
Copy the code into a text file in your home folder name it HAPIR.py
sudo python HAPIR.py 

Step 6: Set the Code to Start at Bootup Using Cron

Type
sudo crontab -e
Go to the bottom and add the following line
@reboot python /home/pi/HAPIR.py &

Enjoy

Comments

About This Instructable

5,675views

26favorites

License:

More by bekkblando:Motion Detected Music-Raspberry Pi
Add instructable to: