StrangeOne
Member
Hi there all,
Trying to get my teensy v3.1 to access my .h audio files in the controllers on-board memory.
I want it to playback 3 different sound files.
The first to be played once when a button is pushed in.
The second to then be played in a loop while the button is held down.
The third to be played once when the button is released.
Trouble is the only syntax reference I've seen for doing this isn't compiling in the main arduino program.
Seems it needs something before the AudioPlayMemory command and says the object it's supposed to create hasn't been declared.
Here is my code so far:
int inPin = 14;
int val = 0;
#include <iostream>
#include "mngs1.h";
#include "mngs2.h";
#include "mngs3.h";
AudioPlayMemory gunSound;
void setup()
{
pinMode(inPin, INPUT); //Sets the digital pin as input:
}
void loop()
{
val = digitalRead(inPin); //Read input pin:
if val == 1
gunSound.play (mngs1.h);
else val = digitalRead(inPin); //Read input pin:
while val == 1
{
gunSound.play(mngs2.h);
val = digitalRead(inPin);
}
gunSound.play(mngs3.h);
}
...............................................................................
Any help on what I'm doing wrong would be appreciated.
Please bare in mind all I've had to go on with my coding is that which I've been able to obtain from online examples of syntax so go easy on me.
Trying to get my teensy v3.1 to access my .h audio files in the controllers on-board memory.
I want it to playback 3 different sound files.
The first to be played once when a button is pushed in.
The second to then be played in a loop while the button is held down.
The third to be played once when the button is released.
Trouble is the only syntax reference I've seen for doing this isn't compiling in the main arduino program.
Seems it needs something before the AudioPlayMemory command and says the object it's supposed to create hasn't been declared.
Here is my code so far:
int inPin = 14;
int val = 0;
#include <iostream>
#include "mngs1.h";
#include "mngs2.h";
#include "mngs3.h";
AudioPlayMemory gunSound;
void setup()
{
pinMode(inPin, INPUT); //Sets the digital pin as input:
}
void loop()
{
val = digitalRead(inPin); //Read input pin:
if val == 1
gunSound.play (mngs1.h);
else val = digitalRead(inPin); //Read input pin:
while val == 1
{
gunSound.play(mngs2.h);
val = digitalRead(inPin);
}
gunSound.play(mngs3.h);
}
...............................................................................
Any help on what I'm doing wrong would be appreciated.
Please bare in mind all I've had to go on with my coding is that which I've been able to obtain from online examples of syntax so go easy on me.
Last edited: