Arduino Control DC Motor Speed with L298N module



Sketch arduino code

int motor1_ena = 3;
int motor1_in1 = 4;
int motor1_in2 = 5;
void setup() {
  // put your setup code here, to run once:
   pinMode( motor1_ena , OUTPUT);
   pinMode( motor1_in1 , OUTPUT);
   pinMode( motor1_in2 , OUTPUT);

   digitalWrite( motor1_in1, HIGH);
   digitalWrite( motor1_in2, LOW );

   analogWrite( motor1_ena , 255); //  change value 0 - 255 for motor speed
}

void loop() {
 

}

ความคิดเห็น