Trigger button to switch sounds

Hey guys, I'm really, REALLY new here and i'm in desperate need of help.

Our university lecturer quite literally chucked an arduino kit at each of us, gave us a brief lesson on how to create circuits and then told us to go on our merry way to come up with a proposal for our end of year projects. I have almost NO background in Processing or Arduino software, so while i can work out very basic scripting, when it comes to anything a little tough I'm completely lost.

Basically part of my project involves using a button as a trigger to switch between two sounds. So basically, when a button is off, it plays sound A. When it's turned on, it switches to sound B. I have 10 different sounds, so that would mean 5 different buttons. I have NO idea how to do this in scripting! Please help!

Who is paying your lecturer? Why isn't s/he doing their job?

He expects us to be resourceful and learn how to do the coding ourselves, but jeez like half the class has no programming background whatsoever. I've only done basic actionscripting!

Well, in your situation, I'd start with the examples already available for the Arduino and Processing.

(What's actionscripting?)

OK name and shame, what University is this?

Groove: Oh haha Actionscript is used for Flash programs. I've done some of the basic tutorials, like how to get switch on an LED light using a button, but i don't know how to incorporate sound into it...

Grumpy_Mike: Hahahaha I can't do that! I'd be in deep shit if it ever gets out. It's a pretty well recognised university, and the lecturers are actually pretty damn good, but as you know, in a barrelful of grenades, there's always a couple of duds. ;)

I'm pretty sure there are Processing examples with sound - it came up on here only the other day - maybe you should ask around your classmates. ;D

As to the switch part - have a look at the Button library and how to use it. Write some simple stuff just to report the switch ID to the serial line, then replace the serial monitor with your Processing.

There are many sound libraries for processing, see this page:-

This one look like what you need:-

Actually it's not even THAT complicated... I have an mp3 file, I just need to figure out how to code it so that it plays when I press a button that's linked to the arduino.... I have absolutely no background in processing or c++ or anything and i'm at my wits end really.. i've trolled the forums for a bit and so far i've found this lil bit of coding:

void loop()
  if (digitalRead(btn_pin) == LOW)

but i don't know how to define the Sound variable and how to stop it when the button is pressed again!

Oh god i sound like a rookie don't i? :(

The arduino is going to need help to play an mp3 file. I believe shields are available or you could butcher an existing mp3 player and hook it up to an arduino. Thats before you start worrying about coding anything, :)

@pluggy, I think he is just using the arduino to control sound in processing


I think your classmate got some answers: