Zum Inhalt springen

Antwort auf: Mega2560 an DRV8825 und Schrittmotor

Projekte und Tutorials für Arduino Foren StartHardware-Forum Mega2560 an DRV8825 und Schrittmotor Antwort auf: Mega2560 an DRV8825 und Schrittmotor

#8586
Clemens Andres
Gast

Hier der allgemein gültige Code, an dem ich versuche den Schrittmotor
ein paar Umdrehungen abzuringen, bisher erfolglos.

/* Hier der einfache StepperMotor Code
* aus dem Internet
* Datum 23.12.2020
* IDE gespeichert unter 2_11
* Ergebnis: “funzt wie erwartet gar nicht”
*/

const int stepPin = 3;
const int dirPin = 4;
void setup() {

pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
}
void loop()
{
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 200; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
delay(1000);
digitalWrite(dirPin,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int x = 0; x < 200; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
//delay(100); // vorher war der Wert 1000 eingesetzt
delayMicroseconds(50); //unklar
}

Code wird vom IDE System angenommen, bei delay kommt es nach einiger Zeit zu einer Meldung wegen
Zeitüberschreitung.