Hello, this is my second post, getting harder
I have a linear actuator Actuonix L16-12V option P, which changes direction by changing the polarity
I just need to manually activate it and decide to move it forward or backward through a button switch and the H-bridge motor driver L293D of the Arduino Uno kit.
I cannot make it moving.
The actuator has 5 cables and I am just using the red and black (motor V+ and V-). Maybe this is a wrong idea.
The code comes from the Ex 10 of the official Arduino Project book, which uses the HBridge, 2 buttons, and a potentiometer to control a rotating DC motor. I "just" reduced to comments the rows of code related to the potentiometer, because I am not interested in the speed. Maybe this is wrong.
I do not know where the error could be and such any help would be appreciated!
const int Hbridge7 = 2;
const int Hbridge2 = 3;
const int HbridgeEnable=9;
const int directionButton =4;
const int onOffButton =5;
const int pot=A0;
int onOffButtonState=0;
int previousOnOffButtonState=0;
int directionButtonState=0;
int previousDirectionButtonState=0;
int motorEnabled=0;
//int motorSpeed=0;
int motorDirection =1;
void setup() {
// put your setup code here, to run once:
pinMode(directionButton, INPUT);
pinMode(onOffButton, INPUT);
pinMode(Hbridge7, OUTPUT);
pinMode(Hbridge2, OUTPUT);
pinMode(HbridgeEnable, OUTPUT);
digitalWrite(HbridgeEnable, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
onOffButtonState=digitalRead(onOffButton);
delay(1);
directionButtonState=digitalRead(directionButton);
//motorSpeed=analogRead(pot)/4;
if(onOffButtonState != previousOnOffButtonState){
if(onOffButtonState ==HIGH){
motorEnabled=!motorEnabled;}
}
if(directionButtonState != previousDirectionButtonState){
if(directionButtonState ==HIGH){
motorDirection=!motorDirection;}
}
if(motorDirection==1){
digitalWrite(Hbridge7, HIGH);
digitalWrite(Hbridge2, LOW);}
else{
digitalWrite(Hbridge7, LOW);
digitalWrite(Hbridge2, HIGH);}
/* if(motorEnabled==1){
analogWrite(HbridgeEnable, motorSpeed);}
else{
analogWrite(HbridgeEnable,0);}
previousDirectionButtonState=directionButtonState;
previousOnOffButtonState=onOffButtonState;*/
}