so basically is what i have is two outputs connected to LED, with a Toggle switch Connected to Pin 7 ("Enable") i need the Outputs to overlap when they Are Flipped back and forth, i have pseudo Code
is pin 7 Enabled
FlipStates
on Enablepin HIGH
linit on 1 mim
if timer = 57 then
rinit on 1 min "60-Seconds"
Timer = 60 Turn linit off
if timer = 57 then
linit on 1 min "60-Seconds"
Timer = 60 Turn rinit off
Loop::
Basically Flipping the Two on and off with a 3 Second Overlap
i will be starting a wokwi Design i will post as well , hopefully Someone can help me out
when the pin changes state, one LED is turned on immediately and a timer started to turned the other LED off 3 secs later. Capture the time when the pin changes state and turn the LED off when the current value of millis() is 3 sec greater than the time when the pin changed state
the Led's are Saving state. can i make them turn off Completely , and it seems the Slide switch isn't turning them off Consistently , any help would be Great
const int switchPin = 8;
const int ledPin1 = 7;
const int ledPin2 = 2;
int switchState = 0;
int ledState1 = LOW;
int ledState2 = HIGH;
void setup() {
pinMode(switchPin, INPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() {
switchState = digitalRead(switchPin);
if (switchState == HIGH) {
ledState1 = !ledState1;
ledState2 = !ledState2;
digitalWrite(ledPin1, ledState1);
delay(250);
digitalWrite(ledPin2, ledState2);
delay(250); // Adjust delay time as needed
if (switchState == LOW) {
ledState1 = !ledState1;
ledState2 = !ledState2;
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
}
}
}
well it's supposed to work like this " when switch is to the right it's enabled" and the LED's turn on and off Flip Flop back and Forth every minute and to the left it stops "disabled" since they dont have a general toggle switch i used the slider