Hi,
We have a high speed camera recording at 500fps and a slower camera recording at 30fps. The high speed camera only records for certain periods during a 3 min trial whereas the 30fps camera records for the whole 3 minutes. To know when the high speed camera is recording in reference to the 30fps camera we wanted the 30fps camera to send a signal to an LED, visible by the high speed camera. The signal would represent the frame number from the 30fps camera as 2 bytes - for example for frame number 22, the LED would light up as 1011000000000000 in the allocated 16 time bins. This way whenever the high speed camera starts recording we would always know what 30fps camera frame we're at. I've written the code below where counter_i is the frame number. The code works for slower timescales (e.g. if the light is on for 0.5s), however that would be too slow if we're sending frame capture signals at 30Hz. I've tried it with 2ms but it seems like it's not performing the computations fast enough as when we stop sending the '4' (frame capture signal for the 30fps camera), the LED still keeps going on and off for a few seconds. If anyone can shed some light on what might be a better way of solving this problem it would be greatly appreciated. Also, I am a complete newbie in Arduino and C++ so this could just be complete nonsense.
char trig = 0;
int LED1_PIN = 9;
int LED3_PIN = 1;
int counter_i = 10;
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0){
trig = Serial.read();
if (trig == '4'){
int remainder = counter_i;
for (int i = 0; i<=15; i++){
int bit_i = remainder % 2;
remainder = remainder / 2;
if (bit_i == 1){
digitalWriteFast(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delayMicroseconds(2000);
digitalWrite(LED_BUILTIN, LOW);
}
else{
delayMicroseconds(2000); // wait for a second
}
}
counter_i++;
}
}
}```