So I have a code for a ring of LEDs to make them chase faster and faster. I have the LEDs connected into the PWM pins arranged so that they are symmetrical, which is why the pins switching on and off in my code jump around a little. Here's the code:

// change the brightness for next time through the loop: brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30); }

at the end of it (I also set int brightness = 0 and int fadeAmount= 5 before the setup), but it did not work correctly. What's the best way to go about this? I've searched around but am having trouble finding the answer. Thanks, guys!

Ahhhh. That is much better. Thank you, Nick. The one thing I understood how to do with the old cumbersome code that I do not with your new, nice and clean code is that once it reaches it's fastest spinning speed (which I would like to be a delay of 10 between lights) I'd like it to spin around at that speed ten times and then begin the pulsing.

My LEDs are very, very bright and I've been getting a bit of a headache working on this. It's too hard for me to not stare at the pretty, blinky LEDs. If I wanted to set them all at a lower brightness, would I just change digitalWrite(pin, HIGH) into digitalWrite(pin, 100) or something like this? Thanks so much.

My LEDs are very, very bright and I've been getting a bit of a headache working on this. It's too hard for me to not stare at the pretty, blinky LEDs. If I wanted to set them all at a lower brightness, would I just change digitalWrite(pin, HIGH) into digitalWrite(pin, 100) or something like this? Thanks so much.

Something like, but not that. digitalWrite is as it's name says, digital. On or off.

You have to use analogWrite to vary the brightness. Only a select number of the pins on the Arduino support analogWrite though.

If I wanted to set them all at a lower brightness, would I just change digitalWrite(pin, HIGH) into digitalWrite(pin, 100) or something like this?

No that won't work. digitalWrite is either on or off.

I did something along those lines a while back, but can't find it. Maybe someone else can. Basically it used a timer to establish a "PWM frequency" and then detect that in an interrupt to make all the pins into PWM pins.

Please post technical questions on the forum, not by personal message. Thanks!

And it's doing it's speed up and then stay at a 20 delay perfectly. Now I'm trying to implement the pulsing after it does it's cycle of doCircle (20)'s by using a modified version of your 'fading 20 LEDs' code, but I'm running into problems. I tried this on it's own as an experiment:

// change the brightness for next time through the loop: brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) fadeAmount = -fadeAmount ;

// wait for 30 milliseconds to see the dimming effect delay(30); } // end of loop

I changed the 'maxPin' to 11, because I didn't want all the LEDs to fade in and out at once (I don't have sufficient power so I only want pins 3, 5, 6, 9, 10, and 11 pulsing) but I only got the pin 3 LED fading. I'm assuming I'm not understanding the maxPin. Just tried your brightness limiting code and it worked perfectly. You're helping so much, Nick. I really aprecciate it. I apologize for the neverending questions, but it's exciting to be learning this stuff, however slow that process may be. You've gotten me to the point where this thing is almost finished! Now I just need it to end with the pulsing loop and have it all activated by a button push. Hehe.

Little confused about bytes. Where are you getting the names 'i' and 'j' from for these bytes? I understand that they are there to store a number, but I'm getting confused on where the letters are coming from.