Dear RC Mineirin,
I have an additional question.
What If I want to run this program again, without having to reset or restart the arduino board? Can this be done by including an attachInterrupt in the void loop(){}?
Or can I use some sort of reset function?
Thank you in advance
volatile byte state = LOW;
volatile unsigned long count = 0; // +1 each time interrupt calls ISR
const byte interruptPin = 2;
int TTL4 = 8;
void isr () {
state = digitalRead(interruptPin);
if (state == HIGH){
count ++;
}
}
void setup() {
//count=0;
pinMode(interruptPin, INPUT_PULLUP);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(TTL4, OUTPUT); //output signal to Syringe pump
digitalWrite(TTL4, state); //original state is when the syringe pump is off
attachInterrupt(state, isr, CHANGE);
}
void loop () {
if (count ==3){
delay(15999);
digitalWrite(LED_BUILTIN, state);
digitalWrite(TTL4,state);
delay(8500);
digitalWrite(TTL4,LOW);
digitalWrite(LED_BUILTIN, LOW);
//delay(10000);
delay(100000);
count=0;
}
attachInterrupt(state, isr, CHANGE);
}