Go to advanced search

by saulton7
Thu Nov 17, 2016 6:09 am
Forum: Python
Topic: Code for a Pi Zero Sound Player
Replies: 13
Views: 2913

Re: Code for a Pi Zero Sound Player

I updated everything and the same events are occurring. Can anyone replicate this on their own Pi's? I'd like to solve this soon please and thanks :D
by saulton7
Tue Nov 15, 2016 7:25 am
Forum: Python
Topic: Code for a Pi Zero Sound Player
Replies: 13
Views: 2913

Re: Code for a Pi Zero Sound Player

This is my try at using GPIOzero. It has been working a little bit better. As the code runs now, I can press the shutdown button and produce the SHUT action as many times as I want, but the BANG action will only work once and then no more. Any help appreciated! I figure that I need to create a loop ...
by saulton7
Tue Nov 15, 2016 7:23 am
Forum: Python
Topic: Code for a Pi Zero Sound Player
Replies: 13
Views: 2913

Re: Code for a Pi Zero Sound Player

import os from gpiozero import Button from subprocess import check_call from signal import pause def shutdown(): #check_call(['sudo', 'poweroff']) print ('SHUT') def laser(): # os.system(mpg123 -q Fire1.mp3 &') print ('BANG') shutdown_btn = Button(17, hold_time=2) shutdown_btn.when_held = shutdown ...
by saulton7
Tue Nov 15, 2016 6:07 am
Forum: Python
Topic: Code for a Pi Zero Sound Player
Replies: 13
Views: 2913

Re: Code for a Pi Zero Sound Player

When I remove the break, there is sort of an error message as in the screen show multiple prints of "shutdown" and the sound for the laser rifle starts to fire erratically. I suspect it has something to do with the inputs and the bouncing effect.
by saulton7
Fri Nov 11, 2016 8:58 pm
Forum: Python
Topic: Code for a Pi Zero Sound Player
Replies: 13
Views: 2913

Re: Code for a Pi Zero Sound Player

Removing the break produces the same result. Any thoughts?
by saulton7
Fri Nov 11, 2016 11:24 am
Forum: Python
Topic: Code for a Pi Zero Sound Player
Replies: 13
Views: 2913

Re: Code for a Pi Zero Sound Player

You could certainly have a script that plays a sound when it starts and then listens for button presses. The best way to learn (in my own view) is to: try some code change it inevitably cause an error search for the error see if I can fix, if I can, move on until I hit #3, if I can't, then I ask fo...
by saulton7
Fri Nov 11, 2016 11:20 am
Forum: Python
Topic: Code for a Pi Zero Sound Player
Replies: 13
Views: 2913

Re: Code for a Pi Zero Sound Player

import os from time import sleep import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(7, GPIO.IN) GPIO.setup(11, GPIO.IN) os.system('mpg123 -q start1.mp3 &') while True: if (GPIO.input(7)): os.system('sudo shutdown -h now &') if (GPIO.input(11)): os.system('mpg123 -q Fire1.mp3 &') break time...
by saulton7
Fri Nov 11, 2016 8:01 am
Forum: Python
Topic: Code for a Pi Zero Sound Player
Replies: 13
Views: 2913

Re: Code for a Pi Zero Sound Player

import RPi.GPIO as GPIO import time import os GPIO.setmode(GPIO.BOARD) GPIO.setup(7, GPIO.IN) GPIO.setup(11, GPIO.IN) aplay /etc/sound/Start.wav while True: if (GPIO.input(7)): os.system("sudo shutdown -h now") if (GPIO.input(11)) == False): aplay /home/pi/Music/Sounds/Fire1.wav time.sleep(0.1); Th...
by saulton7
Fri Nov 11, 2016 7:34 am
Forum: Python
Topic: Code for a Pi Zero Sound Player
Replies: 13
Views: 2913

Code for a Pi Zero Sound Player

Hey all, I am new to Pi's I have used Arduino before but frankly my coding abilities are lacking/very rusty. I am trying to make a Pi zero that is powered from and outside power supply of 5V and does three things -Play a sound file played on startup -Have a safe shutdown sequence activated by button...

Go to advanced search