Loading...
Logo
Processing Forum
I'm sure this is very simple, but I'm new to processing and arduino communication. I have 3 buttons that are hooked up to my arduino uno and I want to be able to press one of the buttons and make a sound file play. Basically I want to be able to press button 1 and sound 1 plays, button 2 and sound 2, button 3 and sound 3. I have no clue what so ever on how to have the two talk to each other. As much help as I could get would be amazing, really looking for the processing code, I think I understand how to send from arduino but that code would be helpful too.

Replies(11)

for beginning arduino with processing i can only recommend using firmata:
(upload standardfirmata to your uno and use the arduino processing library from the link)

now you can just do things like:

arduino = new Arduino(this, Arduino.list()[0], 57600);
if (arduino.digitalRead(5) == Arduino.HIGH) {
      //play sound
}

you might want to check out this to:
notice the input pin is connected to GND via a 10k Ω resistor. this is called pull-down. so you will have a constant LOW reading on your input when the button is not pressed.

for playing sounds, check out minim (sound library that comes with processing)
Examples->Libraries->minim->LoadSample
thank you, but I am getting an error in processing for the line
"arduino = new Arduino(this, Arduino.list()[0], 57600);"
saying "Cannont find anything names "arduino" "
is the four lines of code you gave me the only thing i need to put into processing?
you need to install the arduino library as outlined in my post above. and upload standard firmata to your arduino.

for beginning arduino with processing i can only recommend using firmata:
(upload standardfirmata to your uno and use the arduino processing library from the link) 


I must have something wrong here. So I take the arduino folder that I got from your link and put it in a folder name "library" folder in my processing sketchbook? I don't know if it effects anything but I'm using windows 7 64bit
it should be called "libraries" (not library). 
this is how it should look in your sketchbook folder (aside from the sketches you may have in there):



don't forget to restart processing.
now check out the examples that come with the arduino library under examples->contributed libraries->arduino
I've done all of that and I am still getting the same error.
I have my arduino uno running the standard firmata and processing with the lines you gave me.
you also need import statements and a proper program :) these lines were meant as an example of what you can do.
check out the examples that come with the arduino library instead (as mentioned above). also, if they show up in the examples menu, it means the library is installed correctly. good luck!
Ohhhhh...well now I feel dumb lol. ok so I want to use the arduino input example I'm guessing? It is installed correctly, so I get the arduino input example and add on to it and go from there I'm going to guess? And last question is there any extra code for the arduino I will have to do? so it knows I'm hitting a button and what not? Thank you very much for all your help.
the input example will show you the state of all your digital inputs, so it's a good starting point. try to hook up your button and check with the example.
arduino-software wise you will not need anything other than firmata. with it you can do digitalRead(), digitalWrite(), pinMode() etc. from within processing.
Hi jiokl1,
 
I'm having pretty much the exact same problem as you! (But I'm using photoresisters to trigger the sounds). Did you have any sucess? I have very little Arduino experience, and zero Processing experience and am having problems installing the firmata file. I've downloaded Processing, and have followed the instructions in the link above, but can't find 'firmata' in the Examples folder as described in the instructions. Did you have problems with this??
 
I hope your project is working as it will give me some much needed newbie faith! :-)
Hi orange_fox

With my project it was more of a time killer until some parts came so I never finished this project, but I can help you as much as I can, the firmata file is in the examples in arduino, not processing, which from how I read what you said it seems that is where you are looking. You will install that one the arduino and then use processing to write your new script in to do everything else.

My project I was waiting for parts is working well so there is still hope for yours lol, newbie power!