Arduino UNO TTL pulse generator for optogenetic

Hi all,
I've a question regarding communication between Arduino UNO board and computer. I'm trying to use the Arduino to generate TTL pulse for optogenetic experiments (GitHub - OptogeneticsandNeuralEngineeringCore/Arduino-TTL-Pulse-Generator-and-Controller: Design and Control your experiments with a TTL Generator and Controller) based on ROI activity detection trough Bonsai software. I'm new with the Arduino world and C+ language. the code I'm using is the following:

// CPP Optogenetics stimulation

#define instructionPin 6
#define stimulationPin 8

void setup() {
  pinMode(instructionPin,INPUT);   // Receives inputs from Bonsai-connected Arduino
  pinMode(stimulationPin,OUTPUT); // Trigger Output for the Laser
  Serial.begin(57600);
}

void loop() {

  // 20 Hz, 5ms pulses
  while (digitalRead(instructionPin) == HIGH){
    digitalWrite(stimulationPin, HIGH);   // turn the Laser on 
    delay(5);                 // wait for 5 ms. Change this value to change pulse duration
    digitalWrite(stimulationPin, LOW);    // turn the Laser off
    delay(45);                // wait for 45 ms. Change this value to change pulse frequency
  }
  
  // Laser is off otherwise
  digitalWrite(stimulationPin, LOW); 

}

I was able to modify the parameters of optogenetic stimulation but I couldn't get any output signal when trying to use Arduino trough Bonsai. I think the problem is probably the fact that I'm using a USB as input to Arduino. In particular the string "Define InstructionPin" (while output pin is correct since I can get signal and modify parameters without communicating with the software). how should I change the code to let Arduino get input from USB?

Thank you!!
Giuseppe

how should I change the code to let Arduino get input from USB?

See Serial Basics