Skip to content

Instantly share code, notes, and snippets.

@schappim
Created January 20, 2014 00:04
Show Gist options
  • Select an option

  • Save schappim/8512767 to your computer and use it in GitHub Desktop.

Select an option

Save schappim/8512767 to your computer and use it in GitHub Desktop.
#define CLOCKWISE LOW
#define COUNTERCLOCKWISE HIGH
void stepperSteps( long n ) {
digitalWrite( DIR_PIN, n < 0 ? COUNTERCLOCKWISE : CLOCKWISE );
digitalWrite( ENABLE_PIN, LOW );
n = abs( n );
for( ; n > 0; n-- ) {
PORTB |= _BV(PINB1); // WAY faster than digitalWrite
delayMicroseconds( 50 );
PORTB &= ~_BV(PINB1);
delayMicroseconds( 50 );
}
digitalWrite( ENABLE_PIN, HIGH );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment