diff options
Diffstat (limited to 'arduino_sketch')
-rw-r--r-- | arduino_sketch/rfc4824/rfc4824.ino | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/arduino_sketch/rfc4824/rfc4824.ino b/arduino_sketch/rfc4824/rfc4824.ino index a0a2fd3..9a5e2f6 100644 --- a/arduino_sketch/rfc4824/rfc4824.ino +++ b/arduino_sketch/rfc4824/rfc4824.ino @@ -1,8 +1,10 @@ #include <Stepper.h> -#define ADJ_STP 256 -#define QRT_STP 256 +#define ADJ_STP 32 +#define ADJ_SPEED 128 +#define QRT_STP -256 +#define QRT_SPEED 128 #define CHAR_DELAY 1000 Stepper left_arm(64,4,5,6,7); @@ -12,8 +14,8 @@ int c; void setup() { Serial.begin(9600); - left_arm.setSpeed(128); - right_arm.setSpeed(128); + left_arm.setSpeed(QRT_SPEED); + right_arm.setSpeed(QRT_SPEED); } void loop() { @@ -24,12 +26,16 @@ void adjust(char motor,int steps) { Serial.print("Adjusting "); switch (motor) { case 'l': + left_arm.setSpeed(ADJ_SPEED); Serial.print("left"); left_arm.step(steps); + left_arm.setSpeed(QRT_SPEED); break; case 'r': + right_arm.setSpeed(ADJ_SPEED); Serial.print("right"); right_arm.step(steps); + right_arm.setSpeed(QRT_SPEED); break; } Serial.print(" motor of "); @@ -134,15 +140,15 @@ void set_hex(char digit) { right_arm.step(QRT_STP*2); left_arm.step(QRT_STP); delay(CHAR_DELAY); - right_arm.step(-QRT_STP*2); left_arm.step(-QRT_STP); + right_arm.step(-QRT_STP*2); break; case 0x8: right_arm.step(QRT_STP*3); left_arm.step(QRT_STP); delay(CHAR_DELAY); - right_arm.step(-QRT_STP*3); left_arm.step(-QRT_STP); + right_arm.step(-QRT_STP*3); break; case 0x9: right_arm.step(QRT_STP*4); @@ -194,5 +200,6 @@ void set_hex(char digit) { left_arm.step(QRT_STP*4); break; } + delay(CHAR_DELAY); Serial.println("Returned to home position"); } |