5,710
edits
Changes
→controlling from a Processing app
* In Processing, open a new sketch, and copy this code into it. Save this sketch as "arduino_test" or something like that.
** Try running this sketch. It may give you an error about "COM1" or something of that sort. You need to tell the program what serial port your arduino is connected to. On my computer, I see this output in the Processing window:
Available serial ports:
Stable Library Native lib Version = RXTX-2.1-7 Java lib Version = RXTX-2.1-7 [0] "/dev/tty.modem" [1] "/dev/cu.modem" [2] "/dev/tty.usbserial-A900acnt" [3] "/dev/cu.usbserial-A900acnt" [4] "/dev/tty.Bluetooth-PDA-Sync" [5] "/dev/cu.Bluetooth-PDA-Sync" [6] "/dev/tty.Bluetooth-Modem" [7] "/dev/cu.Bluetooth-Modem"</code>
** I know that my serial port is the "tty.usbserial-A900acnt", which is listed as device number 2 ([2]), so I go back into the processing code and change the line that says <code>port = new Serial</code>... to read <code>port = new Serial(this, Serial.list()[2], 9600);</code>
** Now if I run the sketch again, I know that it will be properly communicating with the Arduino. You will need to modify that line to reflect whichever serial port your arduino is connected to.