Created
March 16, 2019 08:44
-
-
Save samirsogay/93f375aaa7a4a0e7ebf501808d231692 to your computer and use it in GitHub Desktop.
This code is for DOIT Motor Shield which has L293D motor driver and takes a NODEMCU ESP8266 board. With this you can convert BYJ48 stepper motor from Unipolar to Bipolar
This file contains hidden or 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
int A = D1; //EN1 | |
int B = D2; //EN2 | |
int C = D3; //IN1 | |
int D = D4; //IN3 | |
long del = 2000; | |
void setup() { | |
pinMode(A, OUTPUT); | |
pinMode(B, OUTPUT); | |
pinMode(C, OUTPUT); | |
pinMode(D, OUTPUT); | |
digitalWrite(A, HIGH); | |
digitalWrite(B, HIGH); | |
} | |
void one(){ | |
digitalWrite(C, LOW); | |
digitalWrite(D, HIGH); | |
delayMicroseconds(del); | |
} | |
void two(){ | |
digitalWrite(C, LOW); | |
digitalWrite(D, LOW); | |
delayMicroseconds(del); | |
} | |
void three(){ | |
digitalWrite(C, HIGH); | |
digitalWrite(D, LOW); | |
delayMicroseconds(del); | |
} | |
void four(){ | |
digitalWrite(C, HIGH); | |
digitalWrite(D, HIGH); | |
delayMicroseconds(del); | |
} | |
// the loop routine runs over and over again forever: | |
void loop() { | |
for (int i=0; i<=500; i++){ | |
one(); | |
two(); | |
three(); | |
four(); | |
} | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment