Wave shield code, consecutive and non-consecutive sounds

by toby on Thu Oct 18, 2012 2:37 pm

Before I start banging my head against a wall would anyone know if this idea is even possible code wise.

In a nut shell I will have 2 buttons. I want to be able to push button 1 and have the same sound play every time (sound 1). When I push button 2 I want a different sound to play everytime in consecutive order (sound 3,4,5,........50). After sound 50 button 2 would go back to sound file 2 and start over.

So basically you could play sound files like this....
Button 1- sound 1.wav
Button 1- sound 1.wav

Button 2- sound 2.wav
Button 1- sound 1.wav
Button 2- sound 3.wav
Button 2- sound 4.wav

Button 1- sound 1.wav
Button 2- sound 5.wav
and so on......

I'm not a code master by any means so if anyone knew right off the bat if this is not possible it would be a great help.
toby
 
Posts: 14
Joined: Wed Aug 04, 2010 10:12 am

Re: Wave shield code, consecutive and non-consecutive sounds

by adafruit_support_bill on Thu Oct 18, 2012 3:55 pm

That is possible to do with the wave shield & Arduino.
User avatar
adafruit_support_bill
 
Posts: 25601
Joined: Sat Feb 07, 2009 9:11 am

Re: Wave shield code, consecutive and non-consecutive sounds

by toby on Fri Oct 19, 2012 3:03 pm

Awesome, thanks.
I'll start playing with some code then.
toby
 
Posts: 14
Joined: Wed Aug 04, 2010 10:12 am

Re: Wave shield code, consecutive and non-consecutive sounds

by toby on Fri Nov 09, 2012 10:19 pm

Alright I'm finally getting my project to a point where I need to pin down this line of code to play consecutive sound files when one button is pressed.

I'm assuming this code needs tweaked here where I've changed the color to orange but I can't even figure out where to start. Any tips out there???

if (justpressed[2]) {
justpressed[2] = 0;
playcomplete("DO.WAV");
}

I'm largely using this adjusted sketch http://www.ladyada.net/media/wavshield/ ... teonce.pde
toby
 
Posts: 14
Joined: Wed Aug 04, 2010 10:12 am

Re: Wave shield code, consecutive and non-consecutive sounds

by adafruit_support_bill on Sat Nov 10, 2012 5:55 am

code to play consecutive sound files when one button is pressed.

Just call them in the order you want them played:
Code: Select all
if (justpressed[2])
{
justpressed[2] = 0;
playcomplete("DO.WAV");
playcomplete("RE.WAV");
playcomplete("MI.WAV");
}
User avatar
adafruit_support_bill
 
Posts: 25601
Joined: Sat Feb 07, 2009 9:11 am

Re: Wave shield code, consecutive and non-consecutive sounds

by toby on Sat Nov 10, 2012 10:35 am

I'm following you. With that code plugged in though when momentary button 2 is pressed ALL files are played consecutively. I need to get this to do the below...

Button 1- sound 1.wav
wait for button 2 press
Button 2- sound 3.wav
wait for button 2 press
Button 2- sound 4.wav
wait for button 2 press
Button 2- sound 5.wav
wait for button 2 press

After sound 5.wav button 2 press would go back to sound 2.wav (if possible) and start the process over.

I'm guessing some operator needs to take a roll in this? I can't figure out where to even start though.
toby
 
Posts: 14
Joined: Wed Aug 04, 2010 10:12 am

Re: Wave shield code, consecutive and non-consecutive sounds

by adafruit_support_bill on Sat Nov 10, 2012 10:47 am

You need a variable to store what was last played. Then, when button 2 is pressed, you check the variable and decide what to play next. e.g.

Code: Select all
switch (lastPlayed)
{
  case 1:
    playComplete("sound2.wav);
    lastPlayed = 2;
    break;
  case 2:
    playComplete("sound3.wav");
    lastPlayed = 3;

etc...
}
User avatar
adafruit_support_bill
 
Posts: 25601
Joined: Sat Feb 07, 2009 9:11 am

Re: Wave shield code, consecutive and non-consecutive sounds

by xl97 on Sat Nov 10, 2012 1:21 pm

Assuming you still only have your two buttons..

you'd be editing the

Code: Select all
if (justpressed[1]) {
    justpressed[1] = 0;
}


I would think making/using a simple loop and calling the next file incrementally would work?

Code: Select all
char filename[10]; // leave enough room here.
int button2Counter = 0;




Code: Select all
void loop(){
 

  if (justpressed[0]) {
    justpressed[0] = 0; 
    playcomplete("button1_sound.wav");
  }
  if(justpressed[1]){
    justpressed[1] = 0;
    sprintf(filename,"%d.wav", button2Counter);
    playcomplete(filename);
    Serial.println(filename);
    //check it at last file and reset if needed
    if(button2Counter == 50){
      button2Counter = 0;
    }
    else{
      button2Counter++;
    }
  }
}


this isnt tested..

but the idea is to increment a counter/var and use that in the file name loading/playing..


(edit: sorry, posted this last night.. but didnt see error about captcha)
xl97
 
Posts: 144
Joined: Mon Jul 27, 2009 11:51 am

Re: Wave shield code, consecutive and non-consecutive sounds

by toby on Wed Nov 14, 2012 11:29 pm

I really appreciate this help BTW! I've had a few sleepless nights trying to get somewhere on this.

adafruit_support
Where (or how) do I indicate the button2 being pushed? This is my code that's not working (button one is playing a sound fine).
Above the SETUP line I inserted
int lastPlayed = 0;

And this is where I'm having the code issue on button2

Code: Select all
void loop() {
  byte i;
 
  if (justpressed[1]) {
      justpressed[1] = 0;
      playcomplete("1.WAV");
  }
 
      (justpressed[2]);
      justpressed[2] = 0;
 
switch (lastPlayed)
{
  case 1:
    playcomplete("2.wav");
    lastPlayed = 2;
    break;
   
  case 2:
    playcomplete("3.wav");
    lastPlayed = 3;
    break;
   
}
}



xl97
Your solution was working fine until I realized there is a slight (2-3 second) delay in the next track playing after button 2 is pressed. I really thought that your tip was going to work out but I need the .wav to start playing as soon as the button is pushed. I'm not sure why that delay is occuring :( Do you know any reason it's doing this and how to stop it?

Again thanks to both of you!
toby
 
Posts: 14
Joined: Wed Aug 04, 2010 10:12 am

Re: Wave shield code, consecutive and non-consecutive sounds

by adafruit_support_bill on Thu Nov 15, 2012 5:49 am

You need an 'if' before your '(justpressed[2]);'.
User avatar
adafruit_support_bill
 
Posts: 25601
Joined: Sat Feb 07, 2009 9:11 am

Re: Wave shield code, consecutive and non-consecutive sounds

by xl97 on Thu Nov 15, 2012 7:31 am

from 'my' standpoint (but Im new to all this myself still...so take it for what its worth)



1.) as mentioned by support.. you need an 'if' in front to make it conditional check..

2.) if you look at 'my' sample code... you see it checks for button 0 and check for button 1..

arrays (which is what these button instances/names are in).. are all 0 index based..

meaning that you start counting from zero.. not 1 (learn this.. is applies to many languages/programming principles)

so if you have say 3 items/switches in your project..

* first define them and give them their 'pin' numbers as values..

Code: Select all
//custom defined variables
const int playButton =  7;
const int pauseButton =  9;
const int stopButton = 3;



then you need to 'add' these variables to the array..

Code: Select all
//make button array for easy looping/checking
int buttons[] = {playButton, pauseButton, stopButton};




whenever you want to access the data in the array.. you need to remember that INDEX 0 is the first item in the array... not INDEX 1

so there are 3 items in your array above.. you start counting at: 0...etc..

so an example would be:

buttons[0] // thats playButton
buttons[1] // thats pauseButton
buttons[2] // thats stopButton

done..more data/indices




for YOUR example.... I think you need to use pressed[0] and pressed[1] in your code..

make sense? :D



(Your sound issues of not being able to interrupt the sound)

3.) I believe it is because you are using the playComplete() function/method... and it does as it says, plays the song completely.. from beginning to end (no way to stop or interrupt it).



if you scroll down and LOOK at the playComplete() and the playFile() functions.. you'll see a bit of a difference..

At first I didnt understand it much.. seemed odd/redundant to call playComplete() .. that didnt do more than call playFile()...

but if you look.. its actually 'keeping' the stack/pointer 'stuck' in that function.. inside the isplaying() conditional check.. so as long we stuck inside that 'loop'.. we cant do much until the file ends..



That being said.. this is 100% fixable.. and in fact using many of the examples found on this page will show many ways (Adafruit) has handled this..

http://www.ladyada.net/make/waveshield/examples.html


they outline how to play once,, play all the way through.. interrupt play on another button press..etc..etc..

it might seem confusing at first.. but just examine the play functions they have at the bottom, that are a bit different in each sketch..

some check for playing.. then stop it before starting another one....etc. (which is what you are after)

hope this helps!!


take care

-xl
Last edited by xl97 on Thu Nov 15, 2012 9:32 am, edited 1 time in total.
xl97
 
Posts: 144
Joined: Mon Jul 27, 2009 11:51 am

Re: Wave shield code, consecutive and non-consecutive sounds

by toby on Thu Nov 15, 2012 8:27 am

adafruit_support
Through trial and error I tried that 'if' before just pressed as you suggested but it didn't work. I'm sure what your telling me to do is correct though but it's still not working so apparently I've screwed something up here. I didn't really monkey around with the bulk of the example code swiped from the website but I've pasted the whole thing below.

I'm wondering.... Button1 plays fine but Button2 is unresponsive. Button1 is a latching toggle switch and Button2 is a momentary switch. Could the code be snagging because button1 is locked in a pressed state?

Code: Select all
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"

int lastPlayed = 0;


SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

#define DEBOUNCE 5  // button debouncer

// here is where we define the buttons that we'll use. button "1" is the first, button "6" is the 6th, etc
byte buttons[] = {7, 8};
// This handy macro lets us determine how big the array up above is, by checking the size
#define NUMBUTTONS sizeof(buttons)
// we will track if a button is just pressed, just released, or 'pressed' (the current state
volatile byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];

// this handy function will return the number of bytes currently free in RAM, great for debugging!   
int freeRam(void)
{
  extern int  __bss_end;
  extern int  *__brkval;
  int free_memory;
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end);
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval);
  }
  return free_memory;
}

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  byte i;
 
  // set up serial port
  Serial.begin(9600);
  putstring_nl("WaveHC with ");
  Serial.print(NUMBUTTONS, DEC);
  putstring_nl("buttons");
 
  putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad
  Serial.println(freeRam());      // if this is under 150 bytes it may spell trouble!
 
  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
 
  // Make input & enable pull-up resistors on switch pins
  for (i=0; i< NUMBUTTONS; i++) {
    pinMode(buttons[i], INPUT);
    digitalWrite(buttons[i], LOW);
  }
 
  //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
  if (!card.init()) {         //play with 8 MHz spi (default faster!) 
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
    sdErrorCheck();
    while(1);                            // then 'halt' - do nothing!
  }
 
  // enable optimize read - some cards may timeout. Disable if you're having problems
  card.partialBlockRead(true);
 
// Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in
    if (vol.init(card, part))
      break;                             // we found one, lets bail
  }
  if (part == 5) {                       // if we ended up not finding one  :(
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();      // Something went wrong, lets print out why
    while(1);                            // then 'halt' - do nothing!
  }
 
  // Lets tell the user about what we found
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?
 
  // Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);                             // then 'halt' - do nothing!
  }
 
  // Whew! We got past the tough parts.
  putstring_nl("Ready!");
 
  TCCR2A = 0;
  TCCR2B = 1<<CS22 | 1<<CS21 | 1<<CS20;

  //Timer2 Overflow Interrupt Enable
  TIMSK2 |= 1<<TOIE2;


}

SIGNAL(TIMER2_OVF_vect) {
  check_switches();
}

void check_switches()
{
  static byte previousstate[NUMBUTTONS];
  static byte currentstate[NUMBUTTONS];
  byte index;

  for (index = 0; index < NUMBUTTONS; index++) {
    currentstate[index] = digitalRead(buttons[index]);   // read the button
   
    /*     
    Serial.print(index, DEC);
    Serial.print(": cstate=");
    Serial.print(currentstate[index], DEC);
    Serial.print(", pstate=");
    Serial.print(previousstate[index], DEC);
    Serial.print(", press=");
    */
   
    if (currentstate[index] == previousstate[index]) {
      if ((pressed[index] == HIGH) && (currentstate[index] == HIGH)) {
          // just pressed
          justpressed[index] = 1;
      }
      else if ((pressed[index] == LOW) && (currentstate[index] == LOW)) {
          // just released
          justreleased[index] = 1;
      }
      pressed[index] = !currentstate[index];  // remember, digital HIGH means NOT pressed
    }
    //Serial.println(pressed[index], DEC);
    previousstate[index] = currentstate[index];   // keep a running tally of the buttons
  }
}


void loop() {
  byte i;
 
  if (justpressed[1]) {
      justpressed[1] = 0;
      playcomplete("cheer.WAV");
  }
 
  if (justpressed[2]);{
     justpressed[2] = 0;
 
switch (lastPlayed)
{
  case 1:
    playcomplete("1.wav");
    lastPlayed = 1;
    break;
 
  case 2:
    playcomplete("2.wav");
    lastPlayed = 2;
    break;
   
  case 3:
    playcomplete("3.wav");
    lastPlayed = 3;
    break;
   
    case 4:
    playcomplete("4.wav");
    lastPlayed = 4;
    break;
}
}
}




// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  while (wave.isplaying) {
  // do nothing while its playing
  }
  // now its done playing
}

void playfile(char *name) {
  // see if the wave object is currently doing something
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); Serial.print(name); return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); return;
  }
 
  // ok time to play! start playback
  wave.play();
}
toby
 
Posts: 14
Joined: Wed Aug 04, 2010 10:12 am

Re: Wave shield code, consecutive and non-consecutive sounds

by adafruit_support_bill on Thu Nov 15, 2012 9:09 am

Code: Select all
    byte buttons[] = {7, 8};
    // This handy macro lets us determine how big the array up above is, by checking the size
    #define NUMBUTTONS sizeof(buttons)
    // we will track if a button is just pressed, just released, or 'pressed' (the current state
    volatile byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];

You have only 2 buttons defined. In C, arrays are addressed starting from 0. This means that you should be checking justpressed[0] and justpressed[1]. There is no justpressed[2].
User avatar
adafruit_support_bill
 
Posts: 25601
Joined: Sat Feb 07, 2009 9:11 am

Re: Wave shield code, consecutive and non-consecutive sounds

by toby on Thu Nov 15, 2012 12:03 pm

adafruit_support
Oddly when I changed the code to "justpressed[0] and justpressed[1]", button1 (the toggle switch) now plays nothing and button2 (the momentary button) now plays the sound I wanted on button1. :(

I'm kind of hitting a wall where I'm starting to wonder "Did I just bite off more than I can chew?". This circuit is for a sculpture that's 100% built but lacking this crucial electronics component (also did I mention I had a deadline.... :shock: ) Needless to say I'm really freaking stressed out about getting this up and running.

I'm going to monkey around with this a little more today when I get a chance. I really appreciate the fact there are a couple people out there in the Internet tubes willing to help a none coder struggle through this. I'll see what I can accomplish today though and try not hassling you all too much.

Also on a side note I think I changed the code correctly to state my switches are being pulled low with 10k resistors then go high (5v) when pressed. It just occurred to me that this may be screwing something up as well if I incorrectly did that code wise.

xl97
"this is 100% fixable"
That's what I needed to hear right now. I can back up off the ledge now. :wink:

Code: Select all
//do not kill self
#include <FatReader.h>
#include <SdReader.h>
#include <avr/pgmspace.h>
#include "WaveUtil.h"
#include "WaveHC.h"

int lastPlayed = 0;


SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the filesystem on the card
FatReader f;      // This holds the information for the file we're play

WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

#define DEBOUNCE 5  // button debouncer

// here is where we define the buttons that we'll use. button "1" is the first, button "6" is the 6th, etc
byte buttons[] = {7, 8};
// This handy macro lets us determine how big the array up above is, by checking the size
#define NUMBUTTONS sizeof(buttons)
// we will track if a button is just pressed, just released, or 'pressed' (the current state
volatile byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];

// this handy function will return the number of bytes currently free in RAM, great for debugging!   
int freeRam(void)
{
  extern int  __bss_end;
  extern int  *__brkval;
  int free_memory;
  if((int)__brkval == 0) {
    free_memory = ((int)&free_memory) - ((int)&__bss_end);
  }
  else {
    free_memory = ((int)&free_memory) - ((int)__brkval);
  }
  return free_memory;
}

void sdErrorCheck(void)
{
  if (!card.errorCode()) return;
  putstring("\n\rSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  putstring(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}

void setup() {
  byte i;
 
  // set up serial port
  Serial.begin(9600);
  putstring_nl("WaveHC with ");
  Serial.print(NUMBUTTONS, DEC);
  putstring_nl("buttons");
 
  putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad
  Serial.println(freeRam());      // if this is under 150 bytes it may spell trouble!
 
  // Set the output pins for the DAC control. This pins are defined in the library
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
 
  // Make input & enable pull-up resistors on switch pins
  for (i=0; i< NUMBUTTONS; i++) {
    pinMode(buttons[i], INPUT);
    digitalWrite(buttons[i], LOW);
  }
 
  //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
  if (!card.init()) {         //play with 8 MHz spi (default faster!) 
    putstring_nl("Card init. failed!");  // Something went wrong, lets print out why
    sdErrorCheck();
    while(1);                            // then 'halt' - do nothing!
  }
 
  // enable optimize read - some cards may timeout. Disable if you're having problems
  card.partialBlockRead(true);
 
// Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part < 5; part++) {     // we have up to 5 slots to look in
    if (vol.init(card, part))
      break;                             // we found one, lets bail
  }
  if (part == 5) {                       // if we ended up not finding one  :(
    putstring_nl("No valid FAT partition!");
    sdErrorCheck();      // Something went wrong, lets print out why
    while(1);                            // then 'halt' - do nothing!
  }
 
  // Lets tell the user about what we found
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(),DEC);     // FAT16 or FAT32?
 
  // Try to open the root directory
  if (!root.openRoot(vol)) {
    putstring_nl("Can't open root dir!"); // Something went wrong,
    while(1);                             // then 'halt' - do nothing!
  }
 
  // Whew! We got past the tough parts.
  putstring_nl("Ready!");
 
  TCCR2A = 0;
  TCCR2B = 1<<CS22 | 1<<CS21 | 1<<CS20;

  //Timer2 Overflow Interrupt Enable
  TIMSK2 |= 1<<TOIE2;


}

SIGNAL(TIMER2_OVF_vect) {
  check_switches();
}

void check_switches()
{
  static byte previousstate[NUMBUTTONS];
  static byte currentstate[NUMBUTTONS];
  byte index;

  for (index = 0; index < NUMBUTTONS; index++) {
    currentstate[index] = digitalRead(buttons[index]);   // read the button
   
    /*     
    Serial.print(index, DEC);
    Serial.print(": cstate=");
    Serial.print(currentstate[index], DEC);
    Serial.print(", pstate=");
    Serial.print(previousstate[index], DEC);
    Serial.print(", press=");
    */
   
    if (currentstate[index] == previousstate[index]) {
      if ((pressed[index] == HIGH) && (currentstate[index] == HIGH)) {
          // just pressed
          justpressed[index] = 1;
      }
      else if ((pressed[index] == LOW) && (currentstate[index] == LOW)) {
          // just released
          justreleased[index] = 1;
      }
      pressed[index] = !currentstate[index];
    }
    //Serial.println(pressed[index], DEC);
    previousstate[index] = currentstate[index];   // keep a running tally of the buttons
  }
}


void loop() {
  byte i;
 
  if (justpressed[0]) {
      justpressed[0] = 0;
      playcomplete("CHEER.WAV");
  }
 
     (justpressed[1]);
      justpressed[1] = 0;
 
switch (lastPlayed)
{
  case 1:
    playcomplete("ONE.WAV");
    lastPlayed = 1;
    break;
   
  case 2:
    playcomplete("TWO.WAV");
    lastPlayed = 2;
    break;
   
  case 3:
    playcomplete("THREE.WAV");
    lastPlayed = 3;
    break;
   
  case 4:
    playcomplete("FOUR.WAV");
    lastPlayed = 4;
    break;
   
}
}




// Plays a full file from beginning to end with no pause.
void playcomplete(char *name) {
  // call our helper to find and play this name
  playfile(name);
  while (wave.isplaying) {
  // do nothing while its playing
  }
  // now its done playing
}

void playfile(char *name) {
  // see if the wave object is currently doing something
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  // look in the root directory and open the file
  if (!f.open(root, name)) {
    putstring("Couldn't open file "); Serial.print(name); return;
  }
  // OK read the file and turn it into a wave object
  if (!wave.create(f)) {
    putstring_nl("Not a valid WAV"); return;
  }
 
  // ok time to play! start playback
  wave.play();
}
toby
 
Posts: 14
Joined: Wed Aug 04, 2010 10:12 am

Re: Wave shield code, consecutive and non-consecutive sounds

by xl97 on Thu Nov 15, 2012 12:11 pm

Hi-

first lets re-group and check our base..

1.) do you PHYSICALLY have your switches on pins: 7 & 8 (like the code states)
Code: Select all
byte buttons[] = {7, 8};


your first switch/button (which is buttons[0]) is the switch you have connected to PIN 7 on the Arduino.
your second switch/button (which is buttons[1]) is the switch you have connected to PIN 8 on the Arduino.

is this correct?


Also.. what is it you are trying to do even? Explain (not in code) the effect/results you are trying to achieve..

Press a button play a sound... press another button, play a different sound?

if a sound is currently playing when you press a button.. you want the current sound to stop and the new sound to play..is this correct?

if your around for a bit.. (not lagging between posts).. we'll get this fixed before I go to lunch

-xl
xl97
 
Posts: 144
Joined: Mon Jul 27, 2009 11:51 am