How can I tell code Arduino has rebooted

I have a timer that turns on blinking light at boot when it is supposed to be off.

I have this code in my sketch:

if (pushed_lightOn) {
    digitalWrite (holdLightLed, LOW);
    digitalWrite (lightRelay, HIGH);
    timer6Timing = 1;
  }
  if (pushed_lightOff) {
    digitalWrite (holdLightLed, HIGH);
    digitalWrite (lightRelay, LOW);
    digitalWrite (lightLed, LOW);
    timer6Timing = 0;
  }
  if (pushed_lightOn2){ {
   timer6Timing = 1;
  }
  [code]if (timer6Timing == 1);  
    digitalWrite ( lightLedBlink, (millis() % 1200 < 125) ? 5000 : 0 ); // flash LED at 2Hz

I have tried putting:

if (timer6Timing == 0);  
    digitalWrite ( !lightLedBlink, (millis() % 1200 < 125) ? 5000 : 0 ); // flash LED at 2Hz

[/code]

and

digitalWrite ( lightLedBlink, LOW){

[/code][/code]

in the beginning of sketch but light still comes on blinking

what if I told it to turn off each time Arduino boots and that would work how do I do it

The error is probably either in the part of the code you didn't post, or in how you wired the circuit.

Here is entire code if it will help. As far as wiring I am a retired industrial electrician so I know it's wired correctly, and after I push "lightOff" button everything works fine. The timer "fanLedBlink" does the same thing.

#include <LedFlasher.h>

int LDR = A0;     //analog pin to which LDR is connected, here we set it to 0 so it means A0
int LDRValue = 0;      //that's a variable to store LDR values
int light_sensitivity = 150;    //This is the approx value of light surrounding your LDR

const byte holdLightLed = 22;
const byte holdfanLed = 24;
const byte lightLed = 50; //light on led
const byte lightLedBlink = 36; //light on led BLACK
const byte lightRelay = 12; //turn on light
const int fanLed = 52;//
const int fanLedBlink = 38;// fan on led
const int fanRelay = 11; //turn on fan
const byte thermostatOverRideLed = 40;//thermostst override on ledRED
const byte thermostatOverRideRelay = 10; //short thermostat output
const byte tripSensedLed = 42; //tripSensed led
const byte tripSensedPauseLed = 44; //tripSensed led
const byte LDRled = 40;

const int pin_yRelay = 12;
const int pin_lightFanRetime = 31;
const int pin_tripSensed = 13; //laser sensor input
const int pin_tripSensedPause = 35; //laser sensor input bypass
const int pin_fanOn = 14;//button to turn off fan YELLOW
const int pin_fanOn2 = 25;//button to turn off fan
const int pin_fanOff = 16;//button to turn off fan YELLOW
const int pin_theromOverRide = 41; //button to short thermostat output RED
const int pin_lightOn = 43;//button to turn on light
const int pin_lightOn2 = 23;//button to turn on light
const int pin_lightOff = 15;//button to turn off light

//unsigned long currentMillis6; // variables to track millis()
//unsigned long currentMillis5; // variables to track millis()
//unsigned long currentMillis4; // variables to track millis()
unsigned long currentMillis; // variables to track millis()

unsigned long previousMillis6 = 0;
unsigned long previousMillis5 = 0;
unsigned long previousMillis4 = 0;
unsigned long previousMillis3 = 0;
unsigned long previousMillis2 = 0;
unsigned long previousMillis = 0;

unsigned long interval5 =600000UL;
unsigned long interval4 = 420UL;
unsigned long interval =  600000UL;
unsigned long interval2 = 600000UL;
unsigned long interval3 = 2500UL;

byte FanLedBlink = 0;
byte LightLedBlink = 0;
byte tripSensedPause = 0;
byte timer7Timing = 0;
byte timer6Timing = 0;
byte timer5Timing = 0;
byte timer4Timing = 0;
byte timer3Timing = 0;
byte timer2Timing = 0;
byte timer1Timing = 0;
bool pushed_yRelay = false;
bool pushed_lightFanRetime = false;
bool pushed_tripSensed = false;
bool pushed_tripSensedPause = false;
bool pushed_fanOn = false;
bool pushed_fanOn2 = false;
bool pushed_fanOff = false;
bool pushed_theromOverRide = false;
bool pushed_lightOn = false;
bool pushed_lightOn2 = false;
bool pushed_lightOff = false;
int lightRelayState = LOW;
int val = 0;     // variable to store the read value


void setup ()//(void)
{
  Serial.begin(9600);

  //  pinMode (yRelay, OUTPUT);
  pinMode (lightLedBlink, OUTPUT);
  pinMode (lightLed, OUTPUT);
  pinMode (lightRelay, OUTPUT);
  pinMode (fanLedBlink, OUTPUT);
  pinMode (fanLed, OUTPUT);
  pinMode (holdfanLed, OUTPUT);
  pinMode (fanRelay, OUTPUT);
  pinMode (thermostatOverRideLed, OUTPUT);
  pinMode (thermostatOverRideRelay, OUTPUT);
  pinMode (tripSensedLed, OUTPUT);
  pinMode (tripSensedPauseLed, OUTPUT);

  pinMode (holdLightLed, OUTPUT);
  pinMode (LDRled, OUTPUT);

  pinMode (pin_lightFanRetime, INPUT_PULLUP);
  pinMode (pin_tripSensed, INPUT_PULLUP);
  pinMode (pin_tripSensedPause, INPUT_PULLUP);
  pinMode (pin_fanOff, INPUT_PULLUP);
  pinMode (pin_theromOverRide, INPUT_PULLUP);
  pinMode (pin_fanOn, INPUT_PULLUP);
  pinMode (pin_fanOn2, INPUT_PULLUP);
  pinMode (pin_lightOn, INPUT_PULLUP);
  pinMode (pin_lightOn2, INPUT_PULLUP);
  pinMode (pin_lightOff, INPUT_PULLUP);

}

void loop ()
{
  bool prev_yRelay = pushed_yRelay;
  bool prev_lightFanRetime = pushed_lightFanRetime;
  bool prev_tripSensed = pushed_tripSensed;
  bool prev_tripSensedPause = pushed_tripSensedPause;
  bool prev_fanOn = pushed_fanOn;
  bool prev_fanOn2 = pushed_fanOn2;
  bool prev_fanOff = pushed_fanOff;
  bool prev_theromOverRide = pushed_theromOverRide;
  bool prev_lightOff = pushed_lightOff;
  bool prev_lightOn = pushed_lightOn;
  bool prev_lightOn2 = pushed_lightOn2;

  pushed_yRelay = digitalRead (pin_yRelay) == LOW;
  pushed_lightFanRetime = digitalRead (pin_lightFanRetime) == LOW;
  pushed_theromOverRide = digitalRead (pin_theromOverRide) == LOW;
  pushed_tripSensed = digitalRead (pin_tripSensed) == LOW;
  pushed_tripSensedPause = digitalRead (pin_tripSensedPause) == LOW;
  pushed_fanOn = digitalRead (pin_fanOn) == LOW;
  pushed_fanOn2 = digitalRead (pin_fanOn2) == LOW;
  pushed_fanOff = digitalRead (pin_fanOff) == LOW;
  pushed_lightOn = digitalRead (pin_lightOn) == LOW;
  pushed_lightOn2 = digitalRead (pin_lightOn2) == LOW;
  pushed_lightOff = digitalRead (pin_lightOff) == LOW;



  LDRValue = analogRead(LDR);
  Serial.println (LDRValue);


  unsigned long currentMillis = millis();






  //if(currentMillis - previousMillis4 > interval4) {
  // save the last time you blinked the LED
  previousMillis4 = currentMillis;
 {
   digitalWrite (lightLedBlink, LOW);
  }
  
  if (pushed_tripSensedPause)// thermostat override pushed
  {
    digitalWrite(tripSensedPauseLed, HIGH); // turn on light led
    previousMillis3 = currentMillis;
    timer3Timing = 1;
  }
  //   delay(6000);
  if ((currentMillis - previousMillis3 > interval3) && (timer3Timing == 1)) {
    digitalWrite(tripSensedPauseLed, LOW); // turn on light led
    timer3Timing = 0;
  }
  if (pushed_tripSensed) {
    digitalWrite(fanRelay, HIGH);//turn on the relay
    digitalWrite(fanLed, HIGH);//turn on the led
    previousMillis5 = currentMillis;
    timer5Timing = 1;
  }
  if ((currentMillis - previousMillis5 > interval5) && (timer5Timing == 1)) {
    digitalWrite(fanRelay, LOW);//turn on the relay
    digitalWrite(fanLed, LOW);//turn on the led
    timer5Timing = 0;

  }
  if ((LDRValue < light_sensitivity)  && (pushed_tripSensed) && (timer3Timing == 0) || (pushed_lightFanRetime))
    // low light and LASER tripped and timer flag reset OR retime pushed
  {
    digitalWrite(lightRelay, HIGH); // turn on light led
    digitalWrite(lightLed, HIGH); // turn on light led
    digitalWrite(fanRelay, HIGH);//turn on the relay
    digitalWrite(fanLed, HIGH);//turn on the led
    previousMillis = currentMillis;
    timer1Timing = 1;
  }
  // delay(6000);
  if ((currentMillis - previousMillis > interval) && (timer1Timing == 1)) {
    digitalWrite(lightRelay, LOW);//turn off the relay
    digitalWrite(lightLed, LOW); // turn off light led
    digitalWrite(fanRelay, LOW);//turn off the relay
    digitalWrite(fanLed, LOW);//turn off the led
    timer1Timing = 0;
  }

  if (pushed_theromOverRide)// thermostat override pushed
  {
    digitalWrite(thermostatOverRideRelay, HIGH);//turn thermostat override relay on
    digitalWrite(thermostatOverRideLed, HIGH);//turn thermostat override relay led on
    previousMillis2 = currentMillis;
    timer2Timing = 1;
  }
  //   delay(6000);
  if ((currentMillis - previousMillis2 > interval2) && (timer2Timing == 1)) {
    digitalWrite(thermostatOverRideRelay, LOW);//turn thermostat override relay off
    digitalWrite(thermostatOverRideLed, LOW);//turn thermostat override relay led off
    timer2Timing = 0;
  }


  val = digitalRead(pin_tripSensed);   // read the input pin
  digitalWrite(tripSensedLed, !val);    // sets the LED to the button's value




  if (pushed_lightOn) {
    digitalWrite (holdLightLed, LOW);
    digitalWrite (lightRelay, HIGH);
    timer6Timing = 1;
  }
  if (pushed_lightOff) {
    digitalWrite (holdLightLed, HIGH);
    digitalWrite (lightRelay, LOW);
    digitalWrite (lightLed, LOW);
    timer6Timing = 0;
  }
  if (pushed_lightOn2){ {
   timer6Timing = 1;
  }
  if (timer6Timing == 1);  
    digitalWrite ( lightLedBlink, (millis() % 1200 < 125) ? 5000 : 0 ); // flash LED at 2Hz
  }
  
  if (pushed_fanOn) {
    digitalWrite (holdfanLed, LOW);
    digitalWrite (fanRelay, HIGH);

  }
  if (pushed_fanOff) {
    digitalWrite (holdfanLed, HIGH);
    digitalWrite (fanRelay, LOW);
    digitalWrite (fanLed, LOW);

  }
  if (pushed_fanOn2) {
    digitalWrite ( fanLedBlink, (millis() % 1200 < 125) ? 5000 : 0 ); // flash LED at 2Hz
  }
}
if (timer6Timing == 0);

Why is there a ; on the end?

A program of this size must have internal documentation. Especially if you expect other programmers to look at it.

  pinMode (lightLedBlink, OUTPUT);This is the second line that is executed after setup() is entered. What do you suppose the bit value of the associated port is at that time, and will the LED be on or off?

If the LED is active low (generally good design practice), yeah, that code would turn on the LED briefly at the start.

Is it on when you drive the pin low, or when you drive it high?

There's also this bit

  previousMillis4 = currentMillis;
 {
   digitalWrite (lightLedBlink, LOW);
  }

Why are you using a 250 line program to figure out an answer to this problem ?

Write a 5 or 10 line program that just deals with the troublesome stuff.

Then if you still have a problem it will be a lot easier for someone here to give advice.

...R