So all work except when s2p = 1
I'm coming out of a pro mini on pins 7 and 8. thru a 330 ohm resister to transistor and to the LED. For s2p i can run it as 2, 3, 4, 5 or 6 and the LED gives me a fast flash as its programed.
The issue is when i run s2p when i run it as s2p = 1 i get a very very dim flicker. but I can change s2p to = 2 and its normal brightness code is below
int st1 = 1;
int st2 = 1;
int s1p = 1;
int s2p = 1;
const int stro1led = 7; // the pin that the strobe 1 LED is attached to
const int stro2led = 8;
unsigned long s1previousMillis = 0;
unsigned long s2previousMillis = 0;
int s1currentState = 0; // Tracks the current step in the sequence
int s2currentState = 0; // Tracks the current step in the sequence
// Strobe 1
// Define the time for each step in milliseconds
const unsigned long s1p1intervals[4] = {15, 100, 15, 1370}; // pattern 1
const unsigned long s1p2intervals[2] = {15, 1485}; // pattern 2
const unsigned long s1p3intervals[2] = {15, 985}; // pattern 3
const unsigned long s1p4intervals[2] = {15, 735}; // pattern 4
const unsigned long s1p5intervals[2] = {15, 585}; // pattern 5
// Strobe 2
// Define the time for each step in milliseconds
const unsigned long s2p1intervals[4] = {15, 100, 15, 1270}; // pattern 1
const unsigned long s2p2intervals[5] = {750, 15, 100, 15, 620}; // pattern 2
const unsigned long s2p3intervals[3] = {750, 15, 735}; // pattern 3
const unsigned long s2p4intervals[3] = {500, 15, 485}; // pattern 4
const unsigned long s2p5intervals[3] = {375, 15, 360}; // pattern 5
const unsigned long s2p6intervals[3] = {300, 15, 285}; // pattern 5
// Define the LED state for each step (LOW = off, HIGH = on)
// Strobe 1
const int s1p1ledStateValues[4] = {HIGH, LOW, HIGH, LOW }; // pattern 1
const int s1p2ledStateValues[2] = {HIGH, LOW}; // pattern 2
const int s1p3ledStateValues[2] = {HIGH, LOW}; // pattern 3
const int s1p4ledStateValues[2] = {HIGH, LOW}; // pattern 4
const int s1p5ledStateValues[2] = {HIGH, LOW}; // pattern 5
// Strobe 2
const int s2p1ledStateValues[4] = {HIGH, LOW, HIGH, LOW}; // pattern 1
const int s2p2ledStateValues[5] = {LOW, HIGH, LOW, HIGH, LOW}; // pattern 2
const int s2p3ledStateValues[3] = {LOW, HIGH, LOW}; // pattern 3
const int s2p4ledStateValues[3] = {LOW, HIGH, LOW}; // pattern 4
const int s2p5ledStateValues[3] = {LOW, HIGH, LOW}; // pattern 5
const int s2p6ledStateValues[3] = {LOW, HIGH, LOW}; // pattern 6
void setup() {
// pinMode(stro1led, OUTPUT);
// digitalWrite(stro1led, LOW); // Start with the LED off
// pinMode(stro2led, OUTPUT);
// digitalWrite(stro2led, LOW); // Start with the LED off
}
void loop() {
// Strobe
unsigned long s1currentMillis = millis();
unsigned long s2currentMillis = millis();
// Strobe 1
//pattern 1
// Check if it is time to switch to the next step
if (st1 == 1 && s1p == 1 ){
if (s1currentMillis - s1previousMillis >= s1p1intervals[s1currentState]) {
s1previousMillis = s1currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 3)
s1currentState = (s1currentState + 1) % 4;
// Apply the new LED state
digitalWrite(stro1led, s1p1ledStateValues[s1currentState]);
}
}
//pattern 2
// Check if it is time to switch to the next step
else if (st1 == 1 && s1p == 2 ){
if (s1currentMillis - s1previousMillis >= s1p2intervals[s1currentState]) {
s1previousMillis = s1currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 1)
s1currentState = (s1currentState + 1) % 2;
// Apply the new LED state
digitalWrite(stro1led, s1p2ledStateValues[s1currentState]);
}
}
//pattern 3
// Check if it is time to switch to the next step
else if (st1 == 1 && s1p == 3 ){
if (s1currentMillis - s1previousMillis >= s1p3intervals[s1currentState]) {
s1previousMillis = s1currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 1)
s1currentState = (s1currentState + 1) % 2;
// Apply the new LED state
digitalWrite(stro1led, s1p3ledStateValues[s1currentState]);
}
}
//pattern 4
// Check if it is time to switch to the next step
else if (st1 == 1 && s1p == 4 ){
if (s1currentMillis - s1previousMillis >= s1p4intervals[s1currentState]) {
s1previousMillis = s1currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 1)
s1currentState = (s1currentState + 1) % 2;
// Apply the new LED state
digitalWrite(stro1led, s1p4ledStateValues[s1currentState]);
}
}
//pattern 5
// Check if it is time to switch to the next step
else if (st1 == 1 && s1p == 5 ){
if (s1currentMillis - s1previousMillis >= s1p5intervals[s1currentState]) {
s1previousMillis = s1currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 1)
s1currentState = (s1currentState + 1) % 2;
// Apply the new LED state
digitalWrite(stro1led, s1p5ledStateValues[s1currentState]);
}
}
else {
digitalWrite(stro1led, LOW);
} // led off
// Strobe 2
//pattern 1
// Check if it is time to switch to the next step
if (st2 == 1 && s2p == 1 ){
if (s2currentMillis - s2previousMillis >= s2p1intervals[s2currentState]) {
s2previousMillis = s2currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 3)
s2currentState = (s2currentState + 1) % 4; .
// Apply the new LED state
digitalWrite(stro2led, s2p1ledStateValues[s2currentState]);
}
}
//pattern 2
// Check if it is time to switch to the next step
if (st2 == 1 && s2p == 2 ){
if (s2currentMillis - s2previousMillis >= s2p2intervals[s2currentState]) {
s2previousMillis = s2currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 4)
s2currentState = (s2currentState + 1) % 5;
// Apply the new LED state
digitalWrite(stro2led, s2p2ledStateValues[s2currentState]);
}
}
//pattern 3
// Check if it is time to switch to the next step
else if (st2 == 1 && s2p == 3 ){
if (s2currentMillis - s2previousMillis >= s2p3intervals[s2currentState]) {
s2previousMillis = s2currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 2)
s2currentState = (s2currentState + 1) % 3;
// Apply the new LED state
digitalWrite(stro2led, s2p3ledStateValues[s2currentState]);
}
}
//pattern 4
// Check if it is time to switch to the next step
else if (st2 == 1 && s2p == 4 ){
if (s2currentMillis - s2previousMillis >= s2p4intervals[s2currentState]) {
s2previousMillis = s2currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 2)
s2currentState = (s2currentState + 1) % 3;
// Apply the new LED state
digitalWrite(stro2led, s2p4ledStateValues[s2currentState]);
}
}
//pattern 5
// Check if it is time to switch to the next step
else if (st2 == 1 && s2p == 5 ){
if (s2currentMillis - s2previousMillis >= s2p5intervals[s2currentState]) {
s2previousMillis = s2currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 2)
s2currentState = (s2currentState + 1) % 3;
// Apply the new LED state
digitalWrite(stro2led, s2p5ledStateValues[s2currentState]);
}
}
//pattern 6
// Check if it is time to switch to the next step
else if (st2 == 1 && s2p == 6 ){
if (s2currentMillis - s2previousMillis >= s2p6intervals[s2currentState]) {
s2previousMillis = s2currentMillis; // Save the time of the change
// Move to the next state (loops back to 0 after 2)
s2currentState = (s2currentState + 1) % 3;
// Apply the new LED state
digitalWrite(stro2led, s2p6ledStateValues[s2currentState]);
}
}
else {
digitalWrite(stro2led, LOW);
} // led off
}