I've succeeded in making a simple Arduino ATMega328 sound player on my breadboard following this guide/code. . .
(tutorial) http://highlowtech.org/?p=1963
(base source code) http://playground.arduino.cc/Code/PCMAudio
But, here's my major problem: when playing the sound clip from the ATMega on my breadboard in the test, the sound only plays once when there's power coming in from the source -- but using a momentary pushbutton in the power circuit unfortunately only plays the sound for however long the button is held down. What I'd like to know is this: how can I slightly adjust the Arduino code to make the sound pulse in its entirety with each button press, kind of like a trigger or a one-shot timer?
For instance, ideally I'd like to be pressing the pushbutton for just a split-second yet still have the circuit play the entire 3 seconds of audio I have on the ATMega, kind of like the Staples Easy Button. I've done this for an LED with a 555 IC timer on a previous experiment (to have the light stay on for 2-3 seconds when the button is tapped), but now I'd like to do this with sound in the Arduino code for a small project.
My knowledge of Arduino coding is still in a beginner stage, which means I can upload sketches and do some minor modifications where applicable, but nothing too crazy. As far as setting "button on", void-loop, and other related variables, I'm not well-adept in that field yet.
Also, while we're at it, how can I make the code go into a sleep mode when not in use, so my battery doesn't drain? Again, think of my idea as the Staples Easy Button, but using the overall concept of the High-Low Tech Arduino Sound Player in the links above.
Thanks again!
One-shot sound button/trigger for Arduino Sound Player
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 1
- Joined: Sun Jul 20, 2014 3:19 am
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: One-shot sound button/trigger for Arduino Sound Player
You need to move the button from the power supply to a digital input. There are plenty of examples out there for using a button as a digital input. Here's one:
https://learn.adafruit.com/adafruit-ard ... s/overview
That tutorial turns on an LED when the button is pressed. When you've got the button working, you can change it to play your sound instead of turning on the LED.
https://learn.adafruit.com/adafruit-ard ... s/overview
That tutorial turns on an LED when the button is pressed. When you've got the button working, you can change it to play your sound instead of turning on the LED.
Please be positive and constructive with your questions and comments.