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

void loop() {
    if(Serial.available() > 0) {
    incomingByte = Serial.read();

    // Print a white "Done!" to the matrix
    matrix.setCursor(1, 0);
    matrix.setTextColor(matrix.Color333(7, 7, 7));


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:

// 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

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!

  • Please specify what Arduino board you are using. Boards like the Uno reset when you open the serial connection and won't respond till the bootloader has exited. I believe it takes 1-2 seconds. – user2973 Jul 23 '14 at 5:40
  • Just edited the post to specify, sorry about that. I'm using an Arduino Uno. – nicholas79171 Jul 23 '14 at 17:25
  • Your code seems to be assuming that the Arduino is on the first port of the list you fetch, which doesn't sound like it is the case. Anyway, you should first make sure you can trigger your code with the serial monitor in the IDE. – Chris Stratton Jul 23 '14 at 18:23
  • I can easily trigger the code with the serial monitor. I've tried it with Processing going to Serial.list()[0] and Serial.list()[1] but have gotten no results either way. – nicholas79171 Jul 23 '14 at 23:50
  • 1
    What's the output of println(Serial.list());? – The Guy with The Hat Jul 24 '14 at 12:46

When you open a serial connection to Arduino Uno the atmega328 microcontroller is usually reset(this depends if the OS is configured to toggle the DTR serial control signal on/off when a port is opened). Just after a reset the bootloader (optiboot) runs to see if you are trying to upload a new sketch. If the bootloader doesn't receive any meaningful communication it will start your sketch after ~1 sec. All communication sent to the serial port while the bootloader is running is lost.

When you use the serial monitor you are too slow to notice the 1 second where the board won't respond to your commands. But the processing sketch is another story.

The easiest fix will be to insert a delay after you open the serial port and before you send any data.

// Wait 1.2 sec
int start = millis();
while (millis() - start < 1200);

If you would rather use a hardware fix you can connect a 10uF capacitor between RESET and GND pins that will prevent the board from being reset by the usb to serial converter.

  • The resest-on-open behavior is often a configurable property of the host operating system's serial device, but even if configured not to happen it easily could if the board is moved to a different install. – Chris Stratton Jul 24 '14 at 18:18
  • I updated the answer to be more speific – user2973 Jul 24 '14 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.