arduino dc motor with 2 buttons

0
down vote
favorite
I have a problem with my arduino project and I tryed everything to fix it but nothing helps. I am trying to rotate my dc motor with 2 buttons , 1 button is to stop/start rotating on left side, and the second one is for stop/start rotating on the right side .I cant switch the states and if the motor is rotating i cant stop it. The speed is controlled by the Potentiometer and works fine, just the buttons are the Problem. I hope somebody can help me. Thank you :slight_smile:

int enablePin = 11;
int in1Pin = 10;

int in2Pin = 9;

int switchPin = 7; int switchPin1 = 6;

int potPin = 0;

int statusPin= 13; boolean status;

void setup()

{

pinMode(in1Pin, OUTPUT);

pinMode(in2Pin, OUTPUT);

pinMode(enablePin, OUTPUT);

pinMode(switchPin, INPUT_PULLUP); pinMode(switchPin1, INPUT_PULLUP);

pinMode(statusPin,OUTPUT); Serial.begin(9600);

}

void loop()

{

digitalWrite(13,HIGH);

int speed = analogRead(potPin) / 4;

boolean reverse = digitalRead(switchPin); boolean reverse1 = digitalRead(switchPin1);

if(reverse == false){ status = true; } if(reverse1 == false){ status == false; }

setMotor(speed, status);

}

void setMotor(int speed, boolean reverse)

{

analogWrite(enablePin, speed);

digitalWrite(in1Pin, ! reverse);

digitalWrite(in2Pin, reverse);

}

I just add the second button with paint , so dont get confused.

if(reverse1 == false){ status == false; }

status = false?

Powering a motor from the Arduino 5V can cause problems.

Post code in code tags.