Skip to content

Commit

Permalink
Arduino stepper motor code
Browse files Browse the repository at this point in the history
  • Loading branch information
gniezen committed Jan 26, 2014
1 parent b92d31f commit 088f9d8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pump_code/pump_code.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <Stepper.h>

int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;

Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);

void setup()
{
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(in3Pin, OUTPUT);
pinMode(in4Pin, OUTPUT);

// this line is for Leonardo's, it delays the serial interface
// until the terminal window is opened
while (!Serial);

Serial.begin(9600);
motor.setSpeed(20);
}

void loop()
{
if (Serial.available())
{
int steps = Serial.parseInt();
motor.step(steps);
}
}

0 comments on commit 088f9d8

Please sign in to comment.