Motore elettrico temporizzato

Dovrei azionare un motore che deve girare per (x) secondi dx pausa di un secondo e x secondi Sx

When button is pressed, start 1st delay which runs motor right.
When 1st delay is done, pause for 1 second.
When 2nd delay is done, start 3rd delay which runs motor left

Edit: I just noticed I used 10 & -10 for speed. Speed should be between -1 & 1 (with 0.5 being 1/2 speed), so those numbers should be 1 & -1 (or fractions if you do not want full speed).

se invece del motore volessi usare 2 relays che si azionano alernati con una pausa di 1secondo?

If you want to activate relays instead of motor, then link the delay-ACT pin to a relay node instead of the motor node. If only one delay activates each relay, then you don’t need the OR node to combine multiple inputs.


io ho fatto così.
quando premo il pulsante per start lui fa un ciclo
ho bisogno che il funzionamento sia a ciclo continuo e che si fermi ad un comando di stop

The built-in tutorial explains loops (205-loops)

The best solution will depend on exactly what you are trying to do.

If you want a program to loop, then you need to code that in XOD by looping a signal from the bottom of the patch back up to the top. When looping back up the patch, you need to add a ‘defer’ node to allow XOD to properly handle the loop. In this case, you will want the delay-DONE on the lowest delay node to loop back to the first delay node. This means the first delay node now has 2 ways to be triggered (button press to start or pulse looping back), so you need a way to combine these inputs (like I did with the ‘or’ node in my first response where motor controller had 2 ways to get activated).

The tricky part is telling it when to stop looping. One option is to only allow looping if button is NOT pressed (or only if it is still being held down; “correct” solution depends on what the desired functionality is). If you want a second button press (or a 2nd button) to stop the looping, you need a way to remember if you are supposed to be looping or not. The simplest option is a flip-flop. A single button can TGL (toggle) the flip flop, or separate buttons can SET/RST the flip-flop.


Left button starts looping, right button stops looping.
Starting a loop also sets flip-flop so looping will continue.
‘gate’ node blocks pulse causing loop if gate-EN is false (i.e. if flip-flop has been reset)
‘any’ node allows either pulse (button press or loop) to trigger the delay

If you want right button to immediately stop all movement, it should be connected to all delay-RST pins to end all the delay counters. As shown here, it will allow the loop to complete before stopping when it is time to start next loop.

This code will actually allow two or more pulses into the loop. In this case, it just resets the delay timer. In your code with multiple delay nodes, you can have multiple delay nodes active at the same time (probably NOT something you want to allow since it will be attempting to run the motor in two different directions at the same time). To prevent this, you can add a ‘gate’ node between the left button and the ‘any’ node. The gate-EN should be connected to a ‘not’ node, which is fed from the flip-flop-MEM (allow start signal to pass if we are NOT looping)