I'm just beginning to use Processing along side with Arduino and need help linking the two. Just to get started, I just wanted to send a single character (eventually strings) to the Arduino and have the Arduino light up a matrix if the Arduino receives the data.
Here's my code for the Arduino (I'm using an Arduino Uno):
#include <Adafruit_GFX.h> // Core graphics library
#include <RGBmatrixPanel.h> // Hardware-specific library
// Set up the matrix
#define CLK 8
#define LAT A3
#define OE 9
#define A A0
#define B A1
#define C A2
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
int incomingByte = 0; // for incoming serial data
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
matrix.begin();
}
void loop() {
if(Serial.available() > 0) {
incomingByte = Serial.read();
// Print a white "Done!" to the matrix
matrix.setCursor(1, 0);
matrix.setTextSize(0);
matrix.setTextColor(matrix.Color333(7, 7, 7));
matrix.print("Done!");
}
}
And here's the code for Processing:
// Example by Tom Igoe
import processing.serial.*;
// The serial port:
Serial myPort;
// List all the available serial ports:
println(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[1], 9600);
// Send a capital "A" out the serial port
myPort.write(65);
I run the processing sketch and then upload the code to the Arduino, but get nothing. The Arduino is using COM3 and I believe the Processing sketch is too, but that may be where I'm messing up.
If I open up the serial monitor and send some data to the Arduino that way, then the LED lights up fine, but only when I do it through that.
Any help would be appreciated. Thanks!
Serial.list()[0]
andSerial.list()[1]
but have gotten no results either way.println(Serial.list());
?