ported basic structure from the Arduino Stepper library