Projekte und Tutorials für Arduino › Foren › StartHardware-Forum › Mega2560 an DRV8825 und Schrittmotor › Antwort auf: Mega2560 an DRV8825 und Schrittmotor
// OriginalCode der o.g.Internetseite
const int DirPin = 4; // this pin defines direction CW or CCW
const int StepPin = 5; // pulse this pin to move one step
const int SPR = 200; // Steps per revolution
void setup()
{
// Make pins as Outputs
pinMode(StepPin, OUTPUT);
pinMode(DirPin, OUTPUT);
}
void loop()
{
// First let us rotate shaft clockwise
digitalWrite(DirPin, HIGH); // defines the direction to clockwise
// Pulse the step pin
for(int x = 0; x < SPR; x++)
{
digitalWrite(StepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(StepPin, LOW);
delayMicroseconds(1000);
}
delay(1000); // Short delay of one second
// Now rotate shaft counterclockwise
digitalWrite(DirPin, LOW);
// Again pulse the step pin
for(int x = 0; x < SPR; x++)
{
digitalWrite(StepPin, HIGH);
delayMicroseconds(1000);
digitalWrite(StepPin, LOW);
delayMicroseconds(1000);
}
delay(1000); // Short delay of one second
}
Ich schicke den Vorgang gebündelt an euere E-MailAdresse: hallo@starthardware.org
Danke für Eure Bemühungen.