Question about timer

I'm sitting in this situation, that I need to program a timer after my delay count, so after a certain amout of time I need it to count (timer) then i want my output 11 and 12 go low. An example of my programming:

int time = millis(); long eventTime = 0; int delayCount = 0; int a = 0;

void setup() { pinMode(4, INPUT); pinMode(5, INPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, INPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(13, OUTPUT); Serial.begin(9600); }

void loop() { if (digitalRead(4) == HIGH) { digitalWrite(10, LOW); } else { digitalWrite(10, HIGH); }

if (digitalRead(5) == HIGH) { digitalWrite(6, HIGH); digitalWrite(7, HIGH);

} else { digitalWrite(6, LOW); digitalWrite(7, LOW); }

if (digitalRead(5) == HIGH) { a = 0; }

if (digitalRead(5) == LOW) { if (a == 0) { a = 1; digitalWrite(11, HIGH); digitalWrite(12, HIGH); Serial.println("HIGH: 11 - 12"); }

delay(100); delayCount++; if (delayCount == 107 ) { Serial.println("sæt pin 12 low"); digitalWrite(12, LOW); Serial.println("LOW: 12"); delayCount = 0; } } else { digitalWrite(11, LOW); digitalWrite(12, LOW); }

I'm sitting in this situation, that I need to program a timer after my delay count, so after a certain amout of time I need it to count (timer) then i want my output 11 and 12 go low.

So what's going wrong?

I didn't analyze your program super-carefully, but as far as I can tell it should be counting as long as all of the inputs & if-conditions are correct. But how would you know if it's counting, since you never do anything with the count variable?

You didn't say anything about the inputs in your written description....

Maybe add some comments in your program so we can understand the logic of what you're trying to do.

You might want to add a few more Serial.print messages so you can see the input-states, the value of a, and your count, etc.

time should be a type long, although you are not using time or event time.

The demo several things at a time shows how to use millis() to manage timing.

…R