0% found this document useful (0 votes)
27 views2 pages

Simple Test L298P Motor Shield Board

This document describes controlling DC motors using an Arduino UNO and L298P motor shield. It sets up the motor and PWM pins, then loops through motions like clockwise, counterclockwise, and individual motor control.

Uploaded by

Andre Hasibuhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Simple Test L298P Motor Shield Board

This document describes controlling DC motors using an Arduino UNO and L298P motor shield. It sets up the motor and PWM pins, then loops through motions like clockwise, counterclockwise, and individual motor control.

Uploaded by

Andre Hasibuhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

/*

DC Motor control by Arduino UNO and L298P Motor Shield Board


Date : 22/7/2020
*/

int BPWM = 11;


int MotorB1 = 13;
int MotorB2 = 8;

int APWM = 10;


int MotorA1 = 12;
int MotorA2 = 3;

int Buzzer = 4; // PIN Buzzer


int PWMSET = 255; // SET Speed Motor Test 50% = 128 and Test 100% = 255

void setup() {

pinMode(4, OUTPUT); // Buzzer

digitalWrite(4,HIGH);
delay(300);
digitalWrite(4,LOW);
delay(100);

pinMode(12, OUTPUT);
pinMode(3, OUTPUT);
pinMode(10, OUTPUT);

pinMode(13, OUTPUT);
pinMode(8, OUTPUT);
pinMode(11, OUTPUT);
}

void loop() {

// ---- Loop CW --------------


digitalWrite(MotorA1, LOW);
digitalWrite(MotorA2, HIGH);
analogWrite(APWM, PWMSET);

digitalWrite(MotorB1, HIGH);
digitalWrite(MotorB2, LOW);
analogWrite(BPWM, PWMSET);
delay(2000);
// ---- END Loop CW ----------

analogWrite(APWM, 0);
analogWrite(BPWM, 0);
delay(1000);

// ---- Loop CCW -------------


digitalWrite(MotorA1, HIGH);
digitalWrite(MotorA2, LOW);
analogWrite(APWM, PWMSET);

digitalWrite(MotorB1, LOW);
digitalWrite(MotorB2, HIGH);
analogWrite(BPWM, PWMSET);
delay(2000);
// ---- END Loop CCW ----------

analogWrite(APWM, 0);
analogWrite(BPWM, 0);
delay(1000);

// ---- Loop Motor1 CCW -----------


digitalWrite(MotorA1, HIGH);
digitalWrite(MotorA2, LOW);
analogWrite(APWM, PWMSET);

digitalWrite(MotorB1, LOW);
digitalWrite(MotorB2, LOW);
analogWrite(BPWM, 0);
delay(2000);
// ---- END Loop Motor1 CCW --------

analogWrite(APWM, 0);
analogWrite(BPWM, 0);
delay(1000);

// ---- Loop Motor2 CCW ------------


digitalWrite(MotorA1, LOW);
digitalWrite(MotorA2, LOW);
analogWrite(APWM, 0);

digitalWrite(MotorB1, LOW);
digitalWrite(MotorB2, HIGH);
analogWrite(BPWM, PWMSET);
delay(2000);
// ---- END Loop Motor2 CCW --------

analogWrite(APWM, 0);
analogWrite(BPWM, 0);
delay(1000);

digitalWrite(4,HIGH);
delay(300);
digitalWrite(4,LOW);

You might also like