For this program what I’d like it do is using pins 3,5,7,8,9,10,11,12 (connected to LEDs) have it start by turning on pin number 3 for 50ms and then off for 100ms, then go to the next number. Once it reaches the end it turns back counting down now.
The problem I’m experiencing is that I have to make it smooth and use the pins assigned and because I’m not using pins 4 and 6 it’s causing a little bit of a delay. I’ve tried including if statements so that if the int a (counting integer) is equal to them it should just add one to int a and continue. But the delay is still there.
Just to recap: want to count from low-high and high-low without the delay of using none-sequential pins.
NOTE: I have the program running right now in the setup just it has a little delay between runs
Thanks for your time, attached is a fritzing pic and the code itself
int delayon = 50;
int delayoff = 100;
int a = 3;
void setup() {
// initialize the digital pins as an output. DON’T’ FORGET TO USE COMMENTS!
pinMode(7, OUTPUT); // Assigns pin 7 to an output
pinMode(8, OUTPUT); // Assigns pin 8 to an output
pinMode(9, OUTPUT); // Assigns pin 9 to an output
pinMode(10, OUTPUT); // Assigns pin 10 to an output
pinMode(11, OUTPUT); // Assigns pin 11 to an output
pinMode(12, OUTPUT); // Assigns pin 12 to an output
pinMode(3, OUTPUT); // Assigns pin 3 to an output
pinMode(5, OUTPUT); // Assigns pin 5 to an output
for ( int a = 3; a < 13 ; a++ ) //Runs a for loop that int a is equal to 3, until it's greater than 13, it adds one to int a
{
if ( a == 4 || a == 6) {
a + 1;
}
digitalWrite(a, HIGH); // int a, starting at 3 increases everytime it loops until it's greater than 13, as it increases plus one each time it correspondes to the pin used to send an output of ON or HIGH
delay(delayon); //Delay for how much it's on
digitalWrite(a, LOW);
delay(delayoff);
if (a == 12) {
for ( int a = 11; a < 13 ; a-- )
{
if ( a == 4 || a == 6) {
a + 1;
}
digitalWrite(a, HIGH);
delay(delayon);
digitalWrite(a, LOW);
delay(delayoff);
}
}
}
}
void loop() { // Main loop of program
}
P.S. sorry if the post isn’t formatted properly, trying to learn the rules from those stickies