10. November 2010
Lass den Stepper jede Sekunde einen Schritt im Uhrzeigersinn machen und alle fünf Sekunden wieder an den Ausgangspunkt zurückkehren. Film Stepper Motor<pre>/* Pololu A4983 Stepper Driver + Mercury Motor SM-42BYG011-25 Stepper Motor This code lets the stepper motor turn as fast as possible. Use it to measure the current (Ampere) at the motor's power supply. And limit the current with the little potentiometer on the stepper driver. According to the specification (http://www.sparkfun.com/datasheets/Robotics/SM-42BYG011-25.pdf) it's 0.33A If you do not limit the current the motor will be damaged!!! */ // Constants ------------------------------------ #define DIR 3 // Direction Pin #define STEP 2 // Constant #define BUT 4 // Direction Button // Variables ------------------------------------ int counter = 0; // Setup ---------------------------------------- void setup(){ pinMode(DIR, OUTPUT); // Direction is an output pinMode(STEP, OUTPUT); // Step is an output } // Loop ----------------------------------------- void loop(){ stepOnce(); // Step } // Function Definition --------------------------- // the specifications says the low to high transition // must be at least 1 microsecond void stepOnce(){ if (counter < 5) { digitalWrite(DIR, HIGH); // set direction digitalWrite(STEP, HIGH); delay(1000); digitalWrite(STEP, LOW); delay(1); counter++; } else if (counter < 10) { digitalWrite(DIR, LOW); // set direction digitalWrite(STEP, HIGH); delay(1); digitalWrite(STEP, LOW); delay(1); counter++; } else { counter = 0; } }