Skip to content

Instantly share code, notes, and snippets.

@brian-lc
Created November 9, 2010 21:39
Show Gist options
  • Select an option

  • Save brian-lc/669865 to your computer and use it in GitHub Desktop.

Select an option

Save brian-lc/669865 to your computer and use it in GitHub Desktop.
This is a simple Processing script to drive a Nema motor through the Easystepper driver and an Arduino
/********************************************************
** More info about the project at: **
** http://lusorobotica.com/viewtopic.php?t=103&f=106 **
** by TigPT at [url=http://www.LusoRobotica.com]www.LusoRobotica.com[/url] **
*********************************************************/
int dirPin = 2;
int stepperPin = 3;
void setup() {
pinMode(dirPin, OUTPUT);
pinMode(stepperPin, OUTPUT);
}
void step(boolean dir,int steps, int stp_int){
digitalWrite(dirPin,dir);
delay(50);
for(int i=0;i<steps;i++){
digitalWrite(stepperPin, HIGH);
delayMicroseconds(stp_int);
digitalWrite(stepperPin, LOW);
delayMicroseconds(stp_int);
}
}
void loop(){
step(true,160,100);
step(false,160,100);
int s =10;
for(int i=0;i< 10;i++){
step(true,1600,s);
s = s * 2;
}
step(true,1600,100);
delay(500);
step(false,1600*5,100);
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment