How do I know which button is pressed?

I am starting with arduino and I would like to see another program I write to read the buttons I press to make a launch pad or a piano if you like. So, for example, I will have 4 buttons, and when I press button 1, I need to know that button 1 was pressed in my other program written in java, so I can reproduce the sample. I can write a java program that reads input (not arduino input) and reproduces a sample. I can write an arduino program that says which button I pressed in the console. However, I don't know how to link them. Any help?

Edit: I could find what I'm looking for http://playground.arduino.cc/Interfacing/Java

+3


source to share


1 answer


There are different archiving methods, but as you posted the simplest way already, this is a java library that handles serial communication as arduino communicates via usb on a virtual com port.

So, all you need to do is transfer data over the serial port (as usual for arduino ide terminal):



Serial.println(nrOfButtonPressed);

      

And read / evaluate the results through some java serial interface.

+1


source







All Articles