Demo Video: https://youtu.be/4OR4rFsO9XE
Everything I've done has worked on a technical level, but not without some consequences.
The most notable of these consequences is noise in the speaker when idle and during playback.
I've decided to tackle this issue more directly and I'm hoping you can provide some insight.
I stripped down the setup as much as I can and I'm still getting noise above the usual static level.
Setup:
Feather M4 Express (CircuitPython 5.3.0* Bootloader 3.10.0)
PAM8302A - Class D Mono Amplifier
4Ohm 3W Speaker 40mm
1200mAh 3.7V Lipo Battery
SPDT Momentary Limit Switch w/ Roller (Trigger)
*I've run into a number of issues with CP 6.x, so I'm sticking with CP 5.3.0 for now
Code:
Code: Select all
# Audio Only Code 5/4/21
import board
import audioio
from audioio import WaveFile
import digitalio
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn, AnalogOut
audio = audioio.AudioOut(board.A0)
shoot = audioio.WaveFile(open("RayGunPew.wav", "rb"))
trigger = DigitalInOut(board.D11)
trigger.direction = Direction.INPUT
trigger.pull = Pull.UP
# Main loop
while True:
if not trigger.value and not audio.playing:
audio.play(shoot)
Potential Solutions:
Is there a better way to invoke audio playback that might fix this issue? For example, in the Prop-Maker Lightsaber, the audio files are read in a subfunction rather than globally in the "setup" before the main loop.
Is there a version of the Feather that is designed for audio playback that might be more suitable?
Is there a better amplifier I could try?
Is there a protocol within CircuitPython that could "clean" the signal going out of A0 like you would do with a digital input pullup?
It seems like the board and circuits attached to it might be creating interference in the signal from A0 to the amp. Are there techniques to insulate the audio signal before it is amplified?
I understand this might be a lot to digest, but I tried to make things as clear and straightforward as possible.
Any help would be greatly appreciated.
Thanks.