Synchronizing 2 Arduinos to computer with Infrared Camera
in
Integration and Hardware
•
5 months ago
Hi everyone,
I'm working on a project that allows me to draw 3D shapes in the air with an infrared pen.
Currently my infrared camera is communicating to an arduino through I2C. I use Processing to get the data and display it.
The camera gives me X,Y coordinates and I have an ultrasonic range finger giving me depth info.
I want to be able to get depth information by using 2 cameras and parallax differences though. I can't figure out how to get the 2 stations and the computer to communicate together efficiently though. Right now I have the 2 stations plugged in 2 different USB ports on my computer. I'm currently using the code below but there is no response from the system. Perhaps I need to change the code on the arduino? Any advice or pointers to resources?
- import processing.serial.*;
- Serial firstArduinoPort; //creates object "firstArduinoPort" of serial class
- Serial secondArduinoPort; //creates object "secondArduinoPort" of serial class
- void setup()
- {
- size(200,200);
- background(255);
- println(Serial.list()); //prints a list of open ports use this to doublecheck which port is which
- //also make sure to assign correct boud rate
- //initialize serials
- firstArduinoPort = new Serial(this, Serial.list()[0], 115200); //port 4
- firstArduinoPort.bufferUntil(' ');
- secondArduinoPort = new Serial(this, Serial.list()[8], 115200); //port 6
- secondArduinoPort.bufferUntil(' ');
- }
- void draw()
- {
- }
- void serialEvent(Serial myPort) {
- //println("serial event detected");
- println("hey");
- if (myPort == firstArduinoPort) {
- String myString = firstArduinoPort.readStringUntil(' '); //reads string until space -- follow example
- println("first cam");
- println(myString);
- }
- else if (myPort == secondArduinoPort) {
- String myString = secondArduinoPort.readStringUntil(' ');
- println("second cam");
- println(myString);
- }
- }
1