Stephanie VicarteElizabeth VicarteIrak Mayer
Published © GPL3+

MuSticks fun way to keep active during quarantine

MuSticks helps during quarantine by keeping you active in a fun and musical way to keep you healthy.

BeginnerFull instructions provided8 hours594
MuSticks fun way to keep active during quarantine

Things used in this project

Hardware components

Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
×1
Adafruit I2S 3W Stereo Speaker Bonnet for Raspberry Pi
×1
Generic Large Surface Bone Conducting Transducer Exciter with Wires 45mm 4 Ohm 5w
×2
plastic bottle
×1

Story

Read more

Custom parts and enclosures

BBH3.stl

BottleHolder.stl

Speaker.stl

BatteryHolder.stl

Schematics

Straight connections from bonnet to speakers

Code

Bash script to run MPG123

SH
This bash script allows the execution of the MPG123 without the need of an administration account. It takes care of removing the batch process created to execute the MPG123 program.
# Vistelilabs (www.vistelilabs.com). 2020
# initialize variables
selection=0
exec4=0
lastSel=0
PID=0

# exit selection code 2
while [ $selection -ne 2 ]
do
    # Read line from command file
    while read line
    do
        selection="$line"
        # if current selection is not the last read then execute
        if [[ $selection -eq 3 ]] && [[ $lastSel -ne $selection ]]; then
            # Prepare command to execute in the background
            cmd="mpg123 http://ice1.somafm.com/u80s-128-mp3"
            # Execute command and assign process id to variable.
            nohup $cmd > /dev/null & PID=$!
            echo "$PID"
            # Remember last selection so it does not execute again.
            lastSel=selection
            exec4=0
        fi
        if [[ $selection -eq 5 ]] && [[ $lastSel -ne $selection ]]; then
            cmd="mpg123 http://ice1.somafm.com/deepspaceone-128-mp3"
            nohup $cmd > /dev/null & PID=$!
            echo "$PID"
            lastSel=selection
            exec4=0
        fi
        if [[ $selection -eq 6 ]] && [[ $lastSel -ne $selection ]]; then
            cmd="mpg123 http://ice1.somafm.com/poptron-128-mp3"
            nohup $cmd > /dev/null & PID=$!
            echo "$PID"
            lastSel=selection
            exec4=0
        fi
        if [[ $selection -eq 7 ]] && [[ $lastSel -ne $selection ]]; then
            cmd="mpg123 http://ice1.somafm.com/missioncontrol-128-mp3"
            nohup $cmd > /dev/null & PID=$!
            echo "$PID"
            lastSel=selection
            exec4=0
        fi
        if [[ $selection -eq 8 ]] && [[ $lastSel -ne $selection ]]; then
            cmd="mpg123 http://ice1.somafm.com/xmasrocks-128-mp3"
            nohup $cmd > /dev/null & PID=$!
            echo "$PID"
            lastSel=selection
            exec4=0
        fi
        if [[ $selection -eq 4 ]] && [[ $exec4 -eq 0 ]]; then
            cmd="kill $PID"
            echo "$cmd"
            # Kill last submitted process
            nohup $cmd > /dev/null
            PID=0
            lastSel=0
            exec4=1
        fi
    done < runSelection.txt
done

Main web page.

PHP
This program writes to the command file the SomaFM station to be loaded by the MPG123 program.
<?php

// Vistelilabs (www.vistelilabs.com). 2020
//Check if there is a command
if (isset($_GET["action"]))
{
    //Open file to write
    $myfile = fopen("runSelection.txt", "w");
    //Set command to stop current streaming
    fwrite($myfile, "4\n");
    //Make sure to flush buffer to file
    fclose($myfile);
    //Wait, maybe not that necessary
    sleep(1);
    //Select the next stream station
	if ($_GET["action"] == "selEighties")
	{
		$myfile = fopen("runSelection.txt", "w");
		fwrite($myfile, "3\n");
		fclose($myfile);
	}
	if ($_GET["action"] == "selDeepSpace")
	{
		$myfile = fopen("runSelection.txt", "w");
		fwrite($myfile, "5\n");
		fclose($myfile);
	}
	if ($_GET["action"] == "selPoptron")
	{
		$myfile = fopen("runSelection.txt", "w");
		fwrite($myfile, "6\n");
		fclose($myfile);
	}
	if ($_GET["action"] == "selMissionC")
	{
		$myfile = fopen("runSelection.txt", "w");
		fwrite($myfile, "7\n");
		fclose($myfile);
	}
	if ($_GET["action"] == "selXmas")
	{
		$myfile = fopen("runSelection.txt", "w");
		fwrite($myfile, "3\n");
		fclose($myfile);
	}
}

//Load web page
//Standard HTML Web Page
//Use your favority Web creator to put together your interface.
require_once("gallery.html");

?>

runSelection.txt

SH
Command file. Preserve the name as the script uses it to load the command.
2

Credits

Stephanie Vicarte

Stephanie Vicarte

14 projects • 12 followers
Elizabeth Vicarte

Elizabeth Vicarte

13 projects • 7 followers
Irak Mayer

Irak Mayer

18 projects • 10 followers

Comments