Arduino DC Motor Control Tutorial L298N Module




Sketch source code

// Sample and Easy for control DC Motor

int MOTOR1_FORWARD_PIN 4
int MOTOR1_BACKWARD_PIN 5
void setup() {

    pinMode( MOTOR1_FORWARD_PIN , OUTPUT);
    pinMode( MOTOR1_BACKWARD_PIN , OUTPUT);
 
}

void loop() {
   // Forward
    digitalWrite( MOTOR1_FORWARD_PIN , HIGH );
    digitalWrite( MOTOR1_BACKWARD_PIN , LOW );
 
    /*  // BACKWARD
     *  digitalWrite( MOTOR1_FORWARD_PIN , LOW );
        digitalWrite( MOTOR1_BACKWARD_PIN , HIGH );
     */
}

ความคิดเห็น