May 23 2015
Day 30 Sound Test
I have been working diligently on some of the sound bytes I intend to use and the necessary scripting involved triggering the sound bytes at the appropriate time during sensor reading activity. Scripts will be commented appropriately when modified specifically for the Picorder operation. Final code and documentation will be provided later as the project nears completion.
In the accompanying video sound test, I am using the previously dissembled stereo speakers normally used with an mp3 player or Smartphone. I took the system apart and mounted the speaker housing on one side of a perf board and secured it with hot glue and mounted the accompanying circuitry on the reverse side. The original unit was powered by a 1.5 vdc power source and will later on be adapted to draw its power from the Raspberry Pi power source. I supplied power to the speakers with a 1.5 vdc battery and made temporary connections to the Pi sound output jack for the video demonstration.
Within the script are 4 GPIO pins set as input triggers. Each pin is held high in its idle state. When pulled low on a specific GPIO pin, the appropriate sound byte will play through the speaker. I am using temporary sound bytes from Star Trek the original series for testing and these will change to be aligned with the sensors I use later on such as the tricorder or alert sounds. As seen in the video, as I pulled each GPIO pin low (to a ground potential) that action initiated the playing of the particular sound byte identified in the script and associated with the specific pin. The momentary triggering is essential to avoid the instant replaying of the sound byte over and over until it is unintelligible as demonstrated in the video.
Here is the basic code used for this sound test:
#!/usr/bin/env python
import os
from time import sleep
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN)
GPIO.setup(23, GPIO.IN)
GPIO.setup(24, GPIO.IN)
GPIO.setup(25, GPIO.IN)
while True:
if (GPIO.input(18) == False):
os.system('mpg123 -q twohours.mp3 &')
if (GPIO.input(23) == False):
os.system('mpg123 -q access.mp3 &')
if (GPIO.input(24) == False):
os.system('mpg123 -q defense.mp3 &')
if (GPIO.input(25)== False):
os.system('mpg123 -q Destruct.mp3 &')
sleep(0.5);
Speaker mount Hot glued to secure to board L/R channels and amplifier Amplifier power connections Speaker powered up
The above assembly will be positioned inside the final casement along with the Pi and appropriate sensors.
Next blog post is planned to be the multiple sensor testing and scripting for the various sensors. It may also include the readout display either as a graphic or numerical display.
Michael