Last active
November 26, 2016 09:08
-
-
Save webghostx/9ae12c77493924098981cdbef8ef739b to your computer and use it in GitHub Desktop.
Test-Script Schrittmotor mit Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Test-Script Schrittmotor mit Arduino | |
Benötigt wird ein Motortreiber wie zB. der DRV8825 oder A4988. | |
Verdrahtung gemäss Motortreiber-Datenblatt. Elko am Eingang | |
des Motor-Stroms nicht vergessen! | |
Anluss des Steppers am Treiber gemäss Datenblatt vom Stepper. | |
Poti am Treiber gemäss Datenblatt vom Treiber einstellen. | |
http://usysto.net | |
*/ | |
const int pinStep = 4; // Pin-Nummer Schritt | |
const int pinDir = 3; // Pin-Nummer Richtung | |
unsigned long intval = 500; // Frequenz anpassen | |
unsigned long prevMicros; // init | |
unsigned long nowMicros; // init | |
void setup() { | |
pinMode(pinStep, OUTPUT); | |
pinMode(pinDir, OUTPUT); | |
} | |
void loop() { | |
/* | |
Motor bekommt Drehimpuls gemäss vorgegebenem Interval (intval) | |
Wenn alles passt dreht der Motor kontinuierlich | |
*/ | |
nowMicros = micros(); | |
if (nowMicros - prevMicros >= intval) { | |
prevMicros = nowMicros; | |
digitalWrite(pinStep, !digitalRead(pinStep)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mehr auf uSYSto.net