import time
import serial
import random
from pygame import mixer

mixer.init()

running = True
elapsed_time = 0
next_value = 25

serialPort = serial.Serial(port = '/dev/ttyUSB0', baudrate = 115200)

for x in range(3):
    serialPort.readline()

def play_song():
    # picker = random.randint(2, 4)
    global serialPort
    picker = 2
    if picker is 2:
        file_path = '/home/pi/Music/Still_Alive.mp3'
    if picker is 3:
        file_path = '/home/pi/Music/Mario_Theme.mp3'
    if picker is 4:
        file_path = '/home/pi/Music/Tetris_Theme.mp3'
    mixer.music.load(file_path)
    mixer.music.play()
    serialPort.write(picker)
    time.sleep(184)

serialPort.flushInput()
serialPort.flushOutput()

for x in range(100):
    serialPort.write(bytes([0]))
    time.sleep(0.2)

serialPort.write(bytes([1]))

elapsed_time = time.time()

while running:
    print "EL",
    print elapsed_time
    print "CT",
    print time.time()
    if serialPort.inWaiting() > 0:
        next_value = serialPort.readline()
        try:
            next_value = float(next_value)
        except ValueError:
         next_value = float(0)
        serialPort.flushInput()
        print next_value
    if abs(next_value) > 1500:
        elapsed_time = time.time()
        serialPort.write(bytes([1]))
    if abs(elapsed_time - time.time()) >= 15:
        play_song()
        serialPort.write(bytes([0]))

import time
import serial
import random
from pygame import mixer

mixer.init()

running = True
elapsed_time = 0
next_value = 25

serialPort = serial.Serial(port = '/dev/ttyUSB0', baudrate = 115200)

for x in range(3):
    serialPort.readline()

def play_song():
    # picker = random.randint(2, 4)
    global serialPort
    picker = 2
    if picker is 2:
        file_path = '/home/pi/Music/Still_Alive.mp3'
    if picker is 3:
        file_path = '/home/pi/Music/Mario_Theme.mp3'
    if picker is 4:
        file_path = '/home/pi/Music/Tetris_Theme.mp3'
    mixer.music.load(file_path)
    mixer.music.play()
    serialPort.write(picker)
    time.sleep(184)

serialPort.flushInput()
serialPort.flushOutput()

for x in range(100):
    serialPort.write(bytes([0]))
    time.sleep(0.2)

serialPort.write(bytes([1]))

elapsed_time = time.time()

while running:
    print "EL",
    print elapsed_time
    print "CT",
    print time.time()
    if serialPort.inWaiting() > 0:
        next_value = serialPort.readline()
        try:
            next_value = float(next_value)
        except ValueError:
         next_value = float(0)
        serialPort.flushInput()
        print next_value
    if abs(next_value) > 1500:
        elapsed_time = time.time()
        serialPort.write(bytes([1]))
    if abs(elapsed_time - time.time()) >= 15:
        play_song()
        elapsed_time = time.time()
        serialPort.write(bytes([0]))

Update alsa_sound_control.py