Help with programming to control two DC motors with two buttons ...

With button 1 can turn on and off motor1, with button 2 can turn on and off motor2, if one motor is turned on the other motor can not turn on if the button is pressed ... please Help me...

Well..., are you using an Arduino? If so, which one?
What type of motors? Voltage and current requirements? What kind of motor driver?
What kind of buttons and how are they wired?
Post the program you have so far between [code] and [/code]tags.

Arduino Mega, they are push buttons for breadborad, 12V DC motors .30A… im so new at this, is for homework but im lost on this…

int motor1=4;
int motor2=5;
int botton1 = 6;
int botton2= 7;
void setup() {

pinMode(botton1, INPUT);
pinMode(motor1,OUTPUT);
pinMode(motor2,OUTPUT);
botton1 = digitalRead(botton1);
botton2= digitalRead(botton2);
}

void loop() {

}

You cannot connect a 12V motor directly to Arduino, you need a motor driver and a 12VDC power supply, also, how do you have your buttons wired?

You can have a look at e.g. Driving motors, lights, etc. from an Arduino output pin for starters. The “Pin 5V” at the left is the Arduino output pin. Be aware that 30A is very hight current and you really need to pick the correct fet and you might need heatsinks (I did not do the calculations).

For the buttons, have a look at the debounce example that comes with the IDE.

I thought the OP said 0.3 Amps? And yes, you could use transistors and diodes.

outsider:
I thought the OP said 0.3 Amps? And yes, you could use transistors and diodes.

I guess I missed the dot :frowning: