Hi! For my project, I have two Arduinos connected to 1 computer (which is running processing) via two serial ports.
In my setup there are 4 potentiometers and 4 LEDs connected to each Arduino and my goal is to get the potentiometers on one Arduino to fade in and out the LEDs on the other Arduino, as simultaneously as possible.
I've actually gotten the communication to work using the processing-arduino library here:http://www.arduino.cc/playground/Interfacing/Processing
and the Processing code here:
Arduino arduino1, arduino2;
int ledPin1 = 3;
int ledPin2 = 6;
int ledPin3 = 10;
int ledPin4 = 11;
arduino1 = new Arduino(this, Arduino.list(), 57600);
arduino2 = new Arduino(this, Arduino.list(),57600);
bright = arduino2.analogRead(0)/4;
bright = arduino2.analogRead(1)/4;
bright = arduino2.analogRead(2)/4;
bright = arduino2.analogRead(3)/4;
bright = arduino1.analogRead(0)/4;
bright = arduino1.analogRead(1)/4;
bright = arduino1.analogRead(2)/4;
bright = arduino1.analogRead(3)/4;
Then I just loaded onto each Arduino the Standard Firmata code given in the Arduino examples.
My problem is that while the communication works perfect, the connection is extremely extremely slow. When I try to fade LEDs, the update speed is so slow that the LEDs pretty much blink from super dim to super bright!
As a result, I'm trying to program the Arduinos and Processing separately using the "handshake" method given in the communication example "SerialCallResponse." While I can get this method to work for talking between one Arduino and processing, I'm completely lost as to how to connect two Arduinos.
For example, in the Processing code, there is a setup
void serialEvent(Serial myPort)
I can only call this once and it specifies only one serial port (that I know of!) so how would I get it to talk to two serial ports?
Is there another way to get the Arduinos to communicate faster while still keeping the communication happily synced?
Thanks so much for any advice!