Skip to content

Instantly share code, notes, and snippets.

@johnty
Last active December 2, 2019 19:22
Show Gist options
  • Save johnty/b4f00f8ee572a4cbe7654571d211dd58 to your computer and use it in GitHub Desktop.
Save johnty/b4f00f8ee572a4cbe7654571d211dd58 to your computer and use it in GitHub Desktop.
test trigger for latency rig
//Trigger tester:
// use with eso32 lolin d32 pro, but can be adapted for any other
// emits T0 for pin 12
// emits T1 for pin 13 at slightly increasing delays of 100ms
// emits T2 for pin 14 at slightly decreasing delays of 100ms
#define PIN_T0 12
#define PIN_T1 13
#define PIN_T2 14
void setup() {
// put your setup code here, to run once:
pinMode(PIN_T0, OUTPUT);
pinMode(PIN_T1, OUTPUT);
pinMode(PIN_T2, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(PIN_T0, LOW);
digitalWrite(PIN_T1, LOW);
digitalWrite(PIN_T2, LOW);
for (int i = 0; i < 10; i++) {
digitalWrite(LED_BUILTIN, HIGH);
delay(100);
digitalWrite(LED_BUILTIN, LOW);
delay(100);
}
}
int delayCntr1 = 0;
int delayCntr2 = 20;
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(PIN_T0, HIGH);
digitalWrite(PIN_T1, LOW);
digitalWrite(PIN_T2, LOW);
delay(100 + delayCntr1);
digitalWrite(PIN_T0, LOW);
digitalWrite(PIN_T1, HIGH);
digitalWrite(PIN_T2, LOW);
delay(100 + delayCntr2);
digitalWrite(PIN_T0, LOW);
digitalWrite(PIN_T1, LOW);
digitalWrite(PIN_T2, HIGH);
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
delayCntr1 += 2;
delayCntr2 -= 2;
if (delayCntr1 >= 20)
delayCntr1 = 0;
if (delayCntr2 < 0)
delayCntr2 = 20;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment