Multiple intervals

The sketch appears to operate only via the “onTime(X)” value in each of the two loops. That is the on and off time are equal and appear to be controlled by the “onTime(X)” value

I am unable to get the “offTime(X)” to function. I believe (but not sure) it may be due to the “interval” command.

Any help would be GREATLY appreciated.

Brian Krupicka
/*
building_light_r3test.ino
BMK
11/18/2021

https://www.arduino.cc/en/Tutorial/BuiltInExamples/BlinkWithoutDelay
*/

int pinButton12 = 12;

// constants won't change. Used here to set a pin number:
const int ledPin2 = 2;// the number of the LED pin
const int ledPin3 = 3;// the number of the LED pin

// Variables will change:
int ledState2 = LOW; // ledState used to set the LED
int ledState3 = LOW; // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis2 = 0; // will store last time LED was updated
unsigned long previousMillis3 = 0; // will store last time LED was updated

// On and Off Times (as int, max=32secs)
const unsigned int onTime2 = 1000;
const unsigned int offTime2 = 3000;

// On and Off Times (as int, max=32secs)
const unsigned int onTime3 = 9000;
const unsigned int offTime3 = 4000;
// Interval is how long we wait

void setup() {

pinMode(pinButton12, INPUT_PULLUP);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);

// set the digital pin as output:
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);

}

void loop()
{
loop2 ();
loop3 ();
}

void loop2 ()
{
// Interval is how long we wait
int interval = onTime2;
// Interval is how long we wait
// On and Off Times (as int, max=32secs)
{
// Set Pin 2 to state of ledstate2 each timethrough loop()
// If ledstate2 hasn't changed, neither will the pin
digitalWrite(ledPin2, ledState2);

// Grab snapshot of current time, this keeps all timing
// consistent, regardless of how much code is inside the next if-statement
unsigned long currentMillis = millis();

// Compare to previous capture to see if enough time has passed
if ((unsigned long)(currentMillis - previousMillis2) >= interval) {
  // Change wait interval, based on current LED state
  if (ledState2) {
    // LED is currently on, set time to stay off
    interval = offTime2;
  } else {
    // LED is currently off, set time to stay on
    interval = onTime2;
  }
  // Toggle the LED's state, Fancy, eh!?
  ledState2 = !(ledState2);

  // Save the current time to compare "later"
  previousMillis2 = currentMillis;
}
else
{
  if (ledPin2, HIGH);
}
if (digitalRead(pinButton12) == LOW)
  digitalWrite (ledPin2, HIGH);

}
if (digitalRead(pinButton12) == LOW)
digitalWrite (ledPin2, HIGH);
}

void loop3 ()
{
// Interval is how long we wait
int interval = onTime3;
// Interval is how long we wait
// On and Off Times (as int, max=32secs)
{
// Set Pin 3 to state of ledstate3 each timethrough loop()
// If ledstate3 hasn't changed, neither will the pin
digitalWrite(ledPin3, ledState3);

// Grab snapshot of current time, this keeps all timing
// consistent, regardless of how much code is inside the next if-statement
unsigned long currentMillis = millis();

// Compare to previous capture to see if enough time has passed
if ((unsigned long)(currentMillis - previousMillis3) >= interval) {
  // Change wait interval, based on current LED state
  if (ledState3) {
    // LED is currently on, set time to stay off
    interval = offTime3;
  } else {
    // LED is currently off, set time to stay on
    interval = onTime3;
  }
  // Toggle the LED's state, Fancy, eh!?
  ledState3 = !(ledState3);

  // Save the current time to compare "later"
  previousMillis3 = currentMillis;
}
else
{
  if (ledPin3, HIGH);
}
if (digitalRead(pinButton12) == LOW)
  digitalWrite (ledPin3, HIGH);

}
if (digitalRead(pinButton12) == LOW)
digitalWrite (ledPin3, HIGH);
}

etc, etc

Please remember to use code tags when posting code.

You can see that the forum software made a mess of your post.

Please edit it to add code tags (select the code and hit the "</>" editor button).

Read the forum guidelines to see how to properly post code and some hints on how to get the most from this forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

What are you trying to do here ?

Check your syntax.

This solved the problem.
Thank you
Brian K