/* Project: L298N dual h-bridge motor driver module, 1 DC motor, without speed control Function: DC motor rotates one direction then another and stops */ //************************************************************ int IN3 = 5;//input 3 of DC motor 2 attached to digital pin 5 int IN4 = 4;//input 4 of DC motor 2 attached to digital pin 4 //************************************************************ void setup() { pinMode (IN4, OUTPUT);//sets IN4 as OUTPUT pinMode (IN3, OUTPUT);//sets IN3 as OUTPUT } void loop() { //DC motor 2 rotates one direction as signals are different: digitalWrite (IN4, HIGH); digitalWrite (IN3, LOW); delay(4000);//sets delay for 4 seconds //DC motor 2 stopped as signals are the same digitalWrite (IN4, LOW); delay(500);//sets delay for half a second //DC motor 2 rotates another direction as signals are different: digitalWrite (IN3, HIGH); delay(4000);//sets delay for 4 seconds //DC motor 2 stopped as signals are the same digitalWrite (IN3, LOW); delay(4000);//sets delay for 4 seconds }