Newbie wants to know how to do 4 or more things one after another

4 steppers must be controlled one after another in a 3-d printing kind of environment. Move, then extrude, then stop extruding, then move, then move something else, all in a row.

Is this all one long loop? Or linked loops? How is this done?


Wow I just read through these excellent posts, all super, and also looked at the remarkable job Robin2 did of guiding us in the overall creation of a sketch rather than the doomed "copy and fix-up" approach. Although it is very useful to copy sections from off-the-shelf code where you don't know how to do it yourself, I'm still doing that.

This is going to be fine and relatively easy.

In fact, with the easy operator input described in Robin2's post, I'm going to make this whole project work all at once. I was going to have separate Arduino's for separate functions, and then have the operator switch them on and off. Not necessary.

All the best to everyone and thank you very much!

Programs naturally do things one after the other. In your case you'd probably make each operation into a separate function and then call the functions one after the other from the main loop(). See Planning and implementing an Arduino program for details of this and many other program design tips.


This sort of thing is commonly done with a (finite) state machine. These can be implemented with a series of if/else statements but many find the switch/case construct clearer. There's a tutorial in IDE -> file/examples/control and a bunch in the tutorials section of the forum - not to mention the www.

For this specific type of application, Using a generic program on the Arduino that can consume G-Code is a common approach. Then you need something on a PC to generate and then send that G-Code. 3D printers tend to work this way.

If you have some specific move and extrude actions that are always the same you can hard code them in a state machine as mentioned. Alternatively, build the functions slipstick mentioned and just call them from setup.