I am trying to run a linear actuator with a BTS7960 motor driver and an Arduino UNO.
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);
}
}