I am working on this for a motor to move a ship for a project, but i cant seem to get it to work. I have left the code and tinkerCAD schematic to see what's going wrong
/*
*/
// define constants
const int FirstButton = 13; //The button to first the actuator is wired to pin 13
const int SecondButton = 11; //The button to second the actuator is wired to pin 11
const int ClockwisePin = 4; //The input 3 into H-Bridge is wired to pin 4
const int CounterClockwisePin = 2; //The input 4 into H-Bridge is wired to pin 2
const int enablePin = 7;
// setup
void setup() {
pinMode(FirstButton, INPUT); //Sets the first button as an input
pinMode(SecondButton, INPUT); //Sets the second button as an input
pinMode(ClockwisePin, OUTPUT); //Sets the input to the H-Bridge as an output
pinMode(CounterClockwisePin, OUTPUT); //Sets the input to the H-Bridge as an output
pinMode(enablePin, OUTPUT);
}
// loop
void loop() {
int FirstButtonState = digitalRead(FirstButton); //Read and store the state of the First Button
int SecondButtonState = digitalRead(SecondButton); //Read and store the state of the Second Button
if (FirstButtonState == LOW && SecondButtonState == HIGH){ //If the first button is pressed and second button isnt,
digitalWrite(enablePin, HIGH); //then turn the motor on
digitalWrite(ClockwisePin, HIGH); //clockwise
digitalWrite(CounterClockwisePin, LOW);
}
if (SecondButtonState == LOW && FirstButtonState == HIGH){ //If the second button is pressed and first button isnt
digitalWrite(enablePin, HIGH); //then turn the motor on
digitalWrite(ClockwisePin, LOW); //anti clockwise
digitalWrite(CounterClockwisePin, HIGH);
}
}
//end of loop