Hello,
I have a Duemilanove (ATMEGA 328), a laptop (i7) with windows 7 (64 bits), and I have also some problems
I have three cameras and I would like to trigger those cameras with the arduino via a C++ program.
The thing is I want to trigger those camera (in burst mode) one after the other, and display a video at the same time for each camera.
I use the library libvlc.
So first of all here is the arduino program uploaded to the board :
const int myPin1 =4;
const int myPin2 = 7;
const int myPin3 = 8;
int com ;
void setup() {
 Serial.begin(9600);    Â
 pinMode(myPin1, OUTPUT);
 pinMode(myPin2, OUTPUT);
 pinMode(myPin3, OUTPUT);
}
Â
void loop() {
 if (Serial.available() == 3) {
com = Serial.read();
  }
 /*********************/
switch(com)
{
   case 'T':
    digitalWrite(myPin1,HIGH);
   break;
   case 'R':
    digitalWrite(myPin1,LOW);
   break;
   case 'U':
    digitalWrite(myPin2,HIGH);
   break;
   case 'M':
    digitalWrite(myPin2,LOW);
   break;
   case 'V':
    digitalWrite(myPin3,HIGH);
   break;
   case 'N':
    digitalWrite(myPin3,LOW);
   break;  Â
   default:
   break;
}
Â
Serial.println();
}
I found some C++ sources, and modified them a bit to fit my needs. Here is the main file :
main.cpp
#include "vlcWindow.h"
#include "SerialCom.h"
int main(int argc, char *argv[])
{
//create the arduino port (- PORT -)
char *myPort ="COM3";
Serial *myArduino = new Serial(myPort);
if(myArduino->IsConnected()){
std::cout <<"serial connection to COM3"<<std::endl;
}else{
std::cout <<"arduino board not found .."<< std::endl;
}
//create the first vlcWindow (- VLC -)
VlcWindow *vlcWindow1 = new VlcWindow();
vlcWindow1->playFirst();
//create second vlcWindow (- VLC -)
VlcWindow *vlcWindow2 = new VlcWindow();
vlcWindow2->playFirst();
//create second vlcWindow (- VLC -)
VlcWindow *vlcWindow3 = new VlcWindow();
vlcWindow3->playFirst();
//ask for delay
int delay;
std::cout<<"sleep duration in ms : "<<std::endl;
std::cin>>delay;
int serie=0;
while(1)
{
std::cout<<"press Enter"<<std::endl;
std::getchar();
myArduino->WriteData("T",1); //arduino press 1
vlcWindow1->playComp(delay); //play video1
myArduino->WriteData("R",1); //arduino release 1
myArduino->WriteData("U",1); //arduino press 2
vlcWindow2->playComp(delay); //play video2
myArduino->WriteData("M",1); //arduino release 2
myArduino->WriteData("V",1); //arduino press 3
vlcWindow3->playComp(delay); //play video3
myArduino->WriteData("N",1); //arduino release 3
std::cout<<"serie : "<<serie<<std::endl;
serie++;
}
  return 1;
}
The files included for SerialCom.h are the c++ files we can find on the arduino website :
http://arduino.cc/playground/Interfacing/CPPWindows
And the vlcWindow.h is a file found on vlc website, that I modified a bit.
I just load a movie, and set the timeline to first frame, and the function "playComp()" reads the movie.
Ok, so here are what I have :
When I compile for only one camera, and one video, it works perfectly, the arduino receives the message and trigger the cam, synchronised with the video that is played.
When I compile for three cameras, without any video display, (with a Sleep() function instead of playVideo) I have the three cameras triggered one after the other.
BUT : when I compile for the three cameras and the three videos, then, the program will play the first two videos, and while starting the last one, the cameras will finally get triggered, one after the other.. so it is not synchronised at all with the videos..
I also noticed that sometimes it seems that the order of the camera is changed, which is very weird to me. Or it also seems that the arduino consider that the pin are still "HIGH"..
Do you have any suggestion ? What can I do ?
Thanks for your help
-Thomas