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

L298 Motor Driver Test

This Arduino code controls two motors using PWM signals and a LiquidCrystal display. It initializes the motor control pins and provides functions to test each motor's speed by varying the PWM value from 0 to 255 in both forward and reverse directions. The main loop continuously runs the motor tests sequentially.

Uploaded by

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

L298 Motor Driver Test

This Arduino code controls two motors using PWM signals and a LiquidCrystal display. It initializes the motor control pins and provides functions to test each motor's speed by varying the PWM value from 0 to 255 in both forward and reverse directions. The main loop continuously runs the motor tests sequentially.

Uploaded by

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

#include <LiquidCrystal.

h>

int ENA = 9;
int IN1 = 12;
int IN2 = 2;

int ENB = 11;


int IN3 = 10;
int IN4 = A5;

LiquidCrystal LCD (2, 8, 4, 5, 6, 7);

void setup ()
{
pinMode (ENA, OUTPUT);
pinMode (IN1, OUTPUT);
pinMode (IN2, OUTPUT);
pinMode (ENB, OUTPUT);
pinMode (IN3, OUTPUT);
pinMode (IN4, OUTPUT);
Serial.begin (9600);

void test_motor_1 ()
{
LCD.print ("Motor 1 Speed:");
for (int i = 0; i < 256; i++)
{
digitalWrite (IN1, HIGH);
digitalWrite (IN2, LOW);
analogWrite (ENA, i);
delay (50);
Serial.println(i);
}

delay (3000);
digitalWrite (IN1, LOW);

for (int i = 0; i < 256; i++)


{
digitalWrite (IN1, LOW);
digitalWrite (IN2, HIGH);
analogWrite (ENA, i);
delay (50);
Serial.println(i);
}

delay (3000);
digitalWrite (IN2, LOW);
}

void test_motor_2 ()
{
LCD.print ("Motor 2 Speed");
for (int i = 0; i < 256; i++)
{
digitalWrite (IN3, HIGH);
digitalWrite (IN4, LOW);
analogWrite (ENB, i);
delay (50);
Serial.println(i);
}

delay (3000);
digitalWrite (IN3, LOW);

for (int i = 0; i < 256; i++)


{
digitalWrite (IN3, LOW);
digitalWrite (IN4, HIGH);
analogWrite (ENB, i);
delay (50);
Serial.println(i);
}

delay (3000);
digitalWrite (IN4, LOW);
}

void loop()
{
test_motor_1();
test_motor_2();
}

You might also like