I have 3 motor drivers and all 3 other them only seem to only work on one of the 2 sides. I have used a voltmeter to check the voltages across the each of the 2 sections on each motor driver. For all 3 of the motor drivers, 2 of them had one side which had a voltage of 5V (which should be 7.2 volts as thats the power supply) and the other sides of the 2 motor drivers was 0-0.05V (so effectively no voltage). The other motor driver had no voltage from either of the 2 sides. Are all 3 of the motor drivers faulty or have I broke them? The schematic for the motor drivers was as follows:
(Apart from instead of a 12V source, a 7.2V source is used buts thats the amount of Volts I need for the motors. The arduino I used was an Arduino mega rather than an UNO shown in this diagram as I got this diagram off the internet) Heres a link for the place where I ordered the motor drivers from: https://thepihut.com/products/l298n-motor-stepper-driver
Here is my code:
#include <PS2X_lib.h> //for v1.6
int enA = 3;
int in1 = 8;
int in2 = 7;
int enB = 9;
int in3 = 5;
int in4 = 4;
int error = 0;
byte type = 0;
byte vibrate = 0;
int light_one_pin = 36;
int light_two_pin = 38;
bool lights_on = false;
PS2X ps2x;
void setup(){
Serial.begin(9600);
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
pinMode(light_one_pin, OUTPUT);
pinMode(light_two_pin, OUTPUT);
//CHANGES for v1.6 HERE!!! **************PAY ATTENTION*************
for(int x = 0; x < 100; x++)
{
error = ps2x.config_gamepad(13,11,10,12, true, true); //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error
}
error = 0;
}
void loop() {
ps2x.read_gamepad(false, vibrate);
if(ps2x.ButtonPressed(PSB_GREEN) && lights_on == false)
{
digitalWrite(light_one_pin, HIGH);
digitalWrite(light_two_pin, HIGH);
lights_on = true;
Serial.println("on");
}
else if(ps2x.ButtonPressed(PSB_GREEN) && lights_on == true)
{
digitalWrite(light_one_pin, LOW);
digitalWrite(light_two_pin, LOW);
lights_on = false;
Serial.println("off");
}
if(ps2x.Analog(PSS_LY) < 128)
{
digitalWrite(in1, LOW);//all fowards wheel
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
analogWrite(enA, 255);
analogWrite(enB, 255);
Serial.println("forwards");
}
else if(ps2x.Analog(PSS_LY) > 128)
{
digitalWrite(in1, HIGH);//all backwards wheels
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
analogWrite(enA, 255);
analogWrite(enB, 255);
Serial.println("backwards");
}
else if(ps2x.Analog(PSS_LY) == 128)
{
analogWrite(enA, 0);
analogWrite(enB, 0);
Serial.println("stationary");
}
else if(ps2x.Analog(PSS_LX) == 128)
{
//Serial.println("still");
//wheel_steering_servo.write(wheel_steering_servo_angle);
}
Serial.println(ps2x.Analog(PSS_LX));
}