Skip to content

Instantly share code, notes, and snippets.

@gamgoon
Last active October 16, 2015 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamgoon/e9c1536e84ef53ee7207 to your computer and use it in GitHub Desktop.
Save gamgoon/e9c1536e84ef53ee7207 to your computer and use it in GitHub Desktop.
L298N Dual Motor Controller Module and Arduino
const int IN1 = 7;
const int IN2 = 8;
const int ENA = 9;
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
}
void loop() {
// forward
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
analogWrite(9, 80);
delay(1000);
// reverse
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
analogWrite(9, 80);
delay(1000);
// stop
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment