Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created October 21, 2009 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atduskgreg/215494 to your computer and use it in GitHub Desktop.
Save atduskgreg/215494 to your computer and use it in GitHub Desktop.
#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