Hi so i've been working on a robot and wanted both motors to spin at the same time but I can't get it to work. I'm pretty new to Arduino but I have the Arduino motor shield. Both of my motors are DC motors. I have a couple problems. 1.) I don't really know how to code both motors spinning at the same time because when I tried it alternated. 2) Now when I plug any motor into the B ports it doesn't work (even if the program only interacts with motor B). I don't know how to fix either.
This is my code
void setup() {
//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin
//Setup Channel B
pinMode(13, OUTPUT); //Initiates Motor Channel A pin
pinMode(8, OUTPUT); //Initiates Brake Channel A pin
}
void loop(){
forward();
}
void forward() {
//Motor A forward @ full speed
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite(13, HIGH); //Establishes forward direction of Channel A
digitalWrite(8, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
}