< Arduino N° 59 | > Arduino N° 61 |
I motori stepper si possono recuperare agevolmente da una stampante fuori uso.
/*
Stepper Motor Control -
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8,9,10,11 of the Arduino.
The motor should revolve in one direction, then in the other direction.
Modified 24-06-2020 by Achille De Santis
*/
#include <Stepper.h>
const int stepsPerRevolution = 200; // number of steps per revolution for your motor
#define P1 8
#define P2 9
#define P3 10
#define P4 11
Stepper myStepper(stepsPerRevolution, P1, P2, P3, P4); // initialize the stepper library on pins 8 through 11:
void avanti(int p) { myStepper.step(p); } // step in one direction:
void indietro(int p) { myStepper.step(-p); } // step in the other direction:
void setup()
{
myStepper.setSpeed(60); // set the speed at 60 rpm
Serial.begin(9600); // initialize the serial port
}
void loop()
{
Serial.println("clockwise");
avanti(1); // one step in one direction
delay(500);
Serial.println("counterclockwise");
indietro(1); // one step in the other direction
delay(500);
}
Simulazione:
Argomenti correlati: Arduino N° 59 - Pilotaggio Stepper Motor
> Arduino N° 61
Nessun commento:
Posta un commento