Running two Tasks at the same time (Berliner Fernsehturm)

Hi,
i am new here and i am better in CNC-programming than in Arduino. I made a model of the Television Tower in Berlin ( see atteched photo) with 5 LEDs , one on the Top, one in the spinning ball and three on the buttom.I am having a trouble in running two Loops at the same time, one for the LED on the top( On-Off Loop with 1000 Millis delay) and the other Loop for the rest LEDs( constant On-Loop).

I know that i can not use Delay because it means running one Loop each time and i am at a dead end with my very little Know-How :confused: .

Any help is much appreciated :slight_smile:

Samr

You have this:

1 led which must, in a repeating cycle, switch on for 1000mS and off for 1000mS
4 leds which must remain on the whole time

?

I don't see your attached picture.

The demo Several Things at a Time illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

Have a look at Using millis() for timing. A beginners guide if you need more explanation.

...R

Or for another take on the same problem see State Machine

SAMRalbayati:
Hi,
i am new here and i am better in CNC-programming than in Arduino. I made a model of the Television Tower in Berlin ( see atteched photo) with 5 LEDs , one on the Top, one in the spinning ball and three on the buttom.I am having a trouble in running two Loops at the same time, one for the LED on the top( On-Off Loop with 1000 Millis delay) and the other Loop for the rest LEDs( constant On-Loop).

I know that i can not use Delay because it means running one Loop each time and i am at a dead end with my very little Know-How :confused: .

Any help is much appreciated :slight_smile:

Samr

For just the 1 blinking and others ON you can keep your delay but if you would do more, first learn to time with millis() and save yourself a lot of work.

But for this... the leds that stay on, turn on in void setup() and they stay on until you turn them off. If you don't turn them off, they stay on.

And in void loop() you have the things that change, your blinking light.

So 1 is blinking. You can use the Blink sketch for this.
Four LEDs are always on. Just set those pins to HIGH in setup() and don't touch them.

But why even using an Arduino for this? A 555 in astable mode for the blinker, and power to the other four, and you're set.

wvmarle:
But why even using an Arduino for this? A 555 in astable mode for the blinker, and power to the other four, and you're set.

+1 on the reduction. 555 circuits are widely available (many makers, many versions) and the chip is cheap.

wvmarle:
But why even using an Arduino for this? A 555 in astable mode for the blinker, and power to the other four, and you're set.

That would certainly reduce the cost of the parts. But if you know nothing about 555 timers and if you take account of your time it may be more economical to use an Arduino. And learning to use the Arduino might be beneficial for other projects.

...R

Same accounts for learning the 555, possibly the most produced ic in the world. Not that hard to learn. The hardest part I had was getting it to a 50% duty cycle, but even that can be done.

The hardest part I had was getting it to a 50% duty cycle, but even that can be done.

Yes just needs a diode.

Not when the charge/discharge resistance changes all the time (which in my case it does - using it to measure the EC or a liquid). And even with a diode you can't get to 50%.

Use the output of the 555 to charge/discharge the cap and you get an exact 50%. I had to take some extra measures, though, as the resistance can drop to about 10 Ohm and the 555 can't deliver that kind of current.