Step 2The Code
Once I got it all to work, it was actually very simple. Basically the Processing code will be setup like this:
import processing.serial.*;
Serial myPort;
void setup(){
println(Serial.list());
myPort = new Serial(this, Serial.list()[*X*], 9600);
myPort.buffer(1);
size(400, 400);
void draw(){
//some code goes here
}
When setting up your code make sure that your Arduino is connected to your serial port. This is important because the code is attempting to point to the specific arduino that you are using. Run your code and look at the list that will be displayed at the bottom of your Processing window and then change the variable in your code that i have indicated by the *X* to the number of the port that your arduino is connected to. Mine was the third on the list so I put 2 in place of the *X*. Keep in mind that the list is displayed as array entries, this means that the first position is indicated as 0 not 1.
The Arduino code is even simpler to setup:
void setup(){
Serial.begin(9600);
}
I have posted the completed codes for you to take and modify and play with. The arduino is saved as pdxMap.pde and the processing code is saved as serialLEDTest.pde
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|










































