- #include <Stepper.h>
- const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
- // for your motor
- // initialize the stepper library on pins 8 through 11:
- Stepper myStepper(stepsPerRevolution, 5, 6, 7, 8);
- void setup() {
- // set the speed at 60 rpm:
- myStepper.setSpeed(60);
- // initialize the serial port:
- Serial.begin(9600);
- }
- void loop() {
- // step one revolution in one direction:
- Serial.println("clockwise");
- myStepper.step(stepsPerRevolution);
- delay(500);
- // step one revolution in the other direction:
- Serial.println("counterclockwise");
- myStepper.step(-stepsPerRevolution);
- delay(500);
- }
- #include <Stepper.h>
- Stepper _StM1(48,5,7,6,8);
- bool _gen1I = 0;
- bool _gen1O = 0;
- unsigned long _gen1P = 0UL;
- void setup()
- {
- _StM1.setSpeed(200);
- }
- void loop()
- {
- if (1) {if (! _gen1I) { _gen1I = 1; _gen1O = 1; _gen1P = millis(); } } else { _gen1I = 0 ; _gen1O= 0; } if (_gen1I ) { if (_gen1O) { if ( _isTimer( _gen1P , 60000 )) { _gen1P = millis(); _gen1O = 0; } } else { if ( _isTimer( _gen1P , 60000 )) { _gen1P = millis(); _gen1O = 1; } } }
- int b1temp1_StM1;
- if (_gen1O) { b1temp1_StM1 = 1;} else {b1temp1_StM1 = -1;}
- if (1) {_StM1.step(b1temp1_StM1);}
- }
- bool _isTimer(unsigned long startTime, unsigned long period )
- {
- unsigned long currentTime;
- currentTime = millis();
- if (currentTime>= startTime) {return (currentTime>=(startTime + period));} else {return (currentTime >=(4294967295-startTime+period));}
- }

