Newbie question

Hi there! I'm new to Arduino, and I've been tinkering away for the past couple of days. I have a project in mind, and I have come for some guidance if possible!!

My project is to add LEDs doing different things all at the same time to a model. I've learned how to do most of these things on their own (tbh, they're pretty simple things!), but I'm really lost on how to get all the different things to run together at the same time.

My plan is to have 7 LEDs chasing in a circle, one LED fading in and out, and 6 LEDs only slightly fading in and out, all at the same time.

Is this possible? Am I in over my head? Is there a well known guide for doing this?

Many thanks in advance!!!

Quite easy to do once you understand. Here are a couple of tutorials to look at:

BlinkWithoutDelay

Arduino Multiple Things

You will want to avoid the delay() function altogether.

“ all at the same time ”

Then you need to master this tutorial:

Demonstration code for several things at the same time.
http://forum.arduino.cc/index.php?topic=223286.0


“ Am I in over my head?”

Sink or swim, you need to let go of delay() and hang on to millis().

Wonderful stuff, thank you!

Here is a more advanced tutorial.

If you can learn to master it, you should be able to fly to the moon ;).

https://forum.arduino.cc/index.php?topic=525240.0

The biggest hurdle is probably that the Arduino Uno only has 6 PWM pins so you'll need a different Arduino or some additional hardware if you want to dim 7 LEDs.

but I'm really lost on how to get all the different things to run together at the same time.

My plan is to have 7 LEDs chasing in a circle, one LED fading in and out, and 6 LEDs only slightly fading in and out, all at the same time.

You CAN control 7 LEDs "at the same time" and if that's all you're doing there is really no trick to it.

The processor only runs one instruction at a time but if you have a series of instructions that turns-on (or dims) the LEDs in sequence, each instruction only takes microseconds and they will appear to come-on at the same time.

And, you CAN use a short delay() between each instruction.

The only problem with delay() is that program execution pauses during the delay so your program can't do anything during the delay period. So for example, if you wanted read a switch you'd have to wait for the delay, or maybe wait for the whole loop to complete, before the switch would be read and that's usually a problem.

My plan is to have 7 LEDs chasing in a circle, one LED fading in and out, and 6 LEDs

The "secret" is to use a loop and change variables every time through the loop.

In this case you can probably do everything inside your main loop but otherwise there are 3 kinds of loops - while() loops, do-while() loops, and for-loops.

...The two most important concepts in programming are conditional execution (if statements, etc.) and loops (doing something over-and-over, usually until some condition is reached). Once you understand those two concepts you can start writing useful programs.