Solved an interesting problem last week using an Arduino UNO. We needed to sync two IDS Particle Image Velocimetry (PIV) cameras using a hardware trigger.
https://en.wikipedia.org/wiki/Particle_image_velocimetry
The two cameras were different models and had different connectors. There are many ways to trigger the system depending on what action you want to capture.
https://en.ids-imaging.com/tl_files/downloads/techtip/TechTip_GEV_TriggerCtl_EN.pdf
I could have just connected a function generator to the inputs, but instead chose to use an Arduino UNO for more flexibility.
The hardware trigger inputs to these cameras are opto-isolated, so the output from the UNO can be used directly.
So I mounted an Arduino in a box, powered from the USB, added a couple of LEDS and a pushbutton, and a BNC connector for the output.
The software is fairly straight forward.
/* CameraTrigger Last Edit 25 July 2019 by RSC */ // constants won't change. They're used here to set pin numbers: const int PushButtonPin = 5; // the number of the pushbutton pin const int RedLedPin = 4; // the number of the LED pin const int TriggerPin = 3; // the number of the trigger pin const int GreenLedPin = 2; // the number of the LED pin int buttonState = 0; // variable for reading the pushbutton // the setup function runs once when you press reset or power the board void setup() { // initialize digital pins as inputs/outputs. pinMode(RedLedPin, OUTPUT); pinMode(GreenLedPin, OUTPUT); pinMode(TriggerPin, OUTPUT); pinMode(PushButtonPin, INPUT); // initialize serial: Serial.begin(9600); } // the loop function runs over and over again forever void loop() { // read the state of the pushbutton value: buttonState = 0; digitalWrite(RedLedPin, HIGH); digitalWrite(GreenLedPin, LOW); Serial.println("PushButton = Off"); Serial.println("Trigger = Armed"); while (!buttonState){ buttonState = digitalRead(PushButtonPin); } delay(200); Serial.println("PushButton = On"); Serial.println("Trigger = On"); digitalWrite(RedLedPin, LOW); digitalWrite(GreenLedPin, HIGH); buttonState = 0; while(!buttonState){ digitalWrite(TriggerPin, HIGH); // turn the trigger on delay(50); // wait for X miliseconds digitalWrite(TriggerPin, LOW); // turn the trigger off delay(50); // wait for X miliseconds buttonState = digitalRead(PushButtonPin); } delay(1000); }