Created
February 28, 2016 10:24
-
-
Save smching/5f0fc38d51c7d6df16f3 to your computer and use it in GitHub Desktop.
L298N Motor Driver Controller Board
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
#define OUT1 4 //Digital 4 connect to L298 IN1 | |
#define OUT2 5 //Digital 5 connect to L298 IN2 | |
#define OUT3 6 //Digital 6 connect to L298 IN3 | |
#define OUT4 7 //Digital 7 connect to L298 IN4 | |
int motor_speed = 20; //delay 20 milliseconds (smaller is faster) | |
void setup() { | |
pinMode(OUT1, OUTPUT); | |
pinMode(OUT2, OUTPUT); | |
pinMode(OUT3, OUTPUT); | |
pinMode(OUT4, OUTPUT); | |
} | |
void loop() { | |
step(1,0,0,0); //step 1 (L1 ON) | |
step(0,0,1,0); //step 2 (L3 ON) | |
step(0,1,0,0); //step 3 (L2 ON) | |
step(0,0,0,1); //step 4 (L4 ON) | |
} | |
void step(int in1, int in2, int in3, int in4) { | |
digitalWrite(OUT1, in1); | |
digitalWrite(OUT2, in2); | |
digitalWrite(OUT3, in3); | |
digitalWrite(OUT4, in4); | |
delay(motor_speed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment