Linear Actuator is not working with BTS7960

Hello,
I am trying to run linear actuator with BTS7960 motor driver and Arduino UNO. But, the code seems fine, wiring seems fine but after uploading the code, the linear actuator does not start.
I am using two push buttons to extend and retract the actuator.

The code is shown below:
byte mspeed=0;
int RPWM = 5;
int LPWM = 6;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(13, OUTPUT);

pinMode(RPWM,OUTPUT);
pinMode(LPWM,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
if( digitalRead(2) == LOW & digitalRead(4) == HIGH ){
mspeed = 255;
analogWrite(RPWM,0);
analogWrite(LPWM, mspeed);
digitalWrite(13,HIGH);
}
else if( digitalRead(2) == HIGH & digitalRead(4) == LOW ){
mspeed = 255;
analogWrite(RPWM,mspeed);
analogWrite(LPWM, 0);
digitalWrite(13,LOW);
}
else{
analogWrite(RPWM,0);
analogWrite(LPWM, 0);
}

}

I am following the given below circuit diagram and using 12V DC power supply

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

If you get errors when compiling please copy them from the IDE using the "Copy error messages" button and paste the clipboard here in code tags

You have a Serial.begin, but no prints to get your sketch to tell you what it is doing.

Please remember to use code tags when posting code.

Also, & is bitwise AND, but you need logical AND, which is &&

I didn't expect it to, but it is an important distinction to make and learn about.

Now, about the debug prints...

I take it you haven't added any debug prints yet.

Fix that first.

Don't try to debug wearing oven mitts, with ear defenders on, and all the lights turned off.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.