Changing flashing LED by pressing button

Hello everyone!
I’m newbie here and i’m beggining with XOD after 2 years leaving arduino in drawer. So i did simple program for flashing lights into my RC police car.
Now I want to make turning on main strobe lights by pressing one button for a 3sec and change flashing patterns by clicking the same button. Finnaly i want make 5 flashing patterns. But problem is only one - i can’t do this by myself and i can’t find solution for my problem.

Here is my project

Somebody can help me, please?

This isn’t a complete answer, and probably isn’t even exactly what you want, but it should start you in the right direction.

First, you said you want 5 different kinds of flashing (which probably actually means 6 if you want an OFF). My example below doesn’t include OFF and defaults to your initial strobe. To have more than 2 states, you can’t use a flip-flop; you will need something to hold multiple states (like count or buffer).

You want a special action if you hold the button for more than 3 seconds. This means you probably don’t want to do anything when the button is pushed, since you don’t know how long it will be down. You actually want to take action when the button is released (or has been held down for 3 seconds). To have something happen on button release, we will use the pulse-on-false node. Just to be explicit, we will also include a pulse-on-true node to activate the delay node.

So, on the left side, when button is released, we get a pulse-on-false, which will stop the delay timer (we did NOT hold button 3 seconds, or delay is already done anyway), but that will not be allowed through the gate unless the delay node is ACT; if delay is ACT, increment count to get next flash sequence.

On the right side, on button press, we pulse-on-true to start the delay timer to determine if button is pressed for 3 seconds. If the timer expires, we did NOT get a pulse-on-false from button release, so we reset count to go back to initial strobe.

At the bottom, we check if count has gotten too high (we don’t have that many flash sequences). If it has gone too high, we reset count.

Instead of using flip-flop-MEM to determine if flash sequence is active, you will use something like equal node to determine if count node is equal to the number specifying flash sequence.

NOTE: if you will have multiple led nodes for the same port #, you will NOT be able to leave them all active. One way to fix this given your sample code above is to connect the flip-n-times-ACT to led-ACT so the led node is only active when the flip-n-times connected to it is active.

If you want your lights to default to OFF, things get a little more complicated. count node only allows you to force back to zero, or increment, and it will default to zero at power-on. This means to default to off, but be able to force initial strobe, you will probably need to designate count=0 as OFF and count=1 as initial strobe. When button has been held down more than 3 seconds, delay-DONE will have to reset count, but it will also have to go through a defer node and INC count so that increment happens after the reset.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.