LED Circuit coupled with Photosensor

Hi
Thanks for looking into this topic..

I have a fairly simple code (attached)... basically, what I need is to input a photosensor which will dictate whether the code below runs or not (the code, not just the LEDs - there will be many in my project)

So, if its dark, I want the code to run... if its bright, i want it to stay off...

Would anybody have any advice or tips for editing my code?

Thanks

Dara

//CODE

const byte LED01Pin = 13;

void setup()
{
// set the LED pins as output:
pinMode(LED01Pin, OUTPUT);
}

void loop()
{
SequenceRun01(LED01Pin);
}

void SequenceRun01(const byte pin)
{
  unsigned long currentMillis = millis();

  const int sequence[][2] =
  {
    // For each step, the pin state and duration in milliseconds
    {HIGH, 1500},
    {LOW, 2500}
  };

// Calculate the number of steps in the sequence
  const byte sequenceLength = sizeof sequence / sizeof sequence[0];

// A place to store the start time of the current step
  static unsigned long intervalStart = 0;  // 0 means DO THE INITIALIZATION

// A place to store the desired duration of the current step
  static unsigned long interval;

// An index into the sequence of the current step
  static byte index = 0;  // (Yes, you can start at any step in the sequence.)

  if (intervalStart == 0)
  {
    // First time through
    digitalWrite(pin, sequence[index][0]);
    interval = sequence[index][1];  // How long until the next step
    intervalStart = currentMillis;  // When this step started
  }

  if (currentMillis - intervalStart >= interval)
  {
    // The step is over.  Go on to the next step
    index = (index + 1) % sequenceLength;  // '%' is the Modulo (remainder after integer division) operator.

    digitalWrite(pin, sequence[index][0]);  // Is the step HIGH or LOW
    interval = sequence[index][1];  // How long until the next step
    intervalStart = currentMillis;   // When this step started
  }
}

The photosensor will NOT dictate whether or not your code runs. The value you read from it MIGHT be used to define which branch(es) through the code are followed.

SequenceRun01(LED01Pin);

A meaningless name for a function.

Why is it necessary to put all the code that is in that function in a function? loop() is perfectly capable of owning that code.

Nothing in your code gives a rat's ass about any analog device. Why not?

  const int sequence[][2] =
  {
    // For each step, the pin state and duration in milliseconds
    {HIGH, 1500},
    {LOW, 2500}
  };

Why is this local to the function? Recreating this array on every call to the function is necessary?