Created
October 21, 2009 21:50
-
-
Save atduskgreg/215494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Stepper.h> | |
#define STEPS 600 | |
Stepper stepper1(STEPS, 11, 10, 9, 8); | |
Stepper stepper2(STEPS, 7, 6, 5, 4 ); | |
int xKnob = 0; | |
int yKnob = 1; | |
int prevXValue = 0; | |
int prevYValue = 0; | |
void setup(){ | |
Serial.begin(9600); | |
prevXValue = analogRead(xKnob); | |
prevYValue = analogRead(yKnob); | |
stepper1.setSpeed(30); | |
stepper2.setSpeed(30); | |
} | |
void loop(){ | |
int newXValue = analogRead(xKnob); | |
int newYValue = analogRead(yKnob); | |
if((newXValue > prevXValue) || newXValue > 1020){ | |
stepper1.step(-1); | |
} else if((newXValue < prevXValue) || newXValue < 2){ | |
stepper1.step(1); | |
} | |
if((newYValue > prevYValue) || newYValue > 1020){ | |
stepper2.step(-1); | |
} else if((newYValue < prevYValue) || newYValue < 2){ | |
stepper2.step(1); | |
} | |
prevXValue = newXValue; | |
prevYValue = newYValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment