Hi, sorry for this naive question. New to Arduino.
The code of Sparkfun example Circuit_12 is quoted here:
// We'll be controlling the motor from pin 9.
// This must be one of the PWM-capable pins.
const int motorPin = 9;
// Set up the motor pin to be an output:
// Set up the serial port:
// Here we've used comments to disable some of the examples.
// To try different things, uncomment one of the following lines
// and comment the other ones. See the functions below to learn
// what they do and how they work.
// This function will let you type a speed into the serial
// monitor window. Open the serial monitor using the magnifying-
// glass icon at the top right of the Arduino window. Then
// type your desired speed into the small text entry bar at the
// top of the window and click "Send" or press return. The motor
// will then operate at that speed. The valid range is 0 to 255.
Serial.println("Type a speed (0-255) into the box above,");
Serial.println("then click [send] or press [return]");
Serial.println(); // Print a blank line
// In order to type out the above message only once,
// we'll run the rest of this function in an infinite loop:
while(true) // "true" is always true, so this will loop forever.
// First we check to see if incoming data is available:
while (Serial.available() > 0)
// If it is, we'll use parseInt() to pull out any numbers:
speed = Serial.parseInt();
// Because analogWrite() only works with numbers from
// 0 to 255, we'll be sure the input is in that range:
speed = constrain(speed, 0, 255);
// We'll print out a message to let you know that the
// number was received:
Serial.print("Setting speed to ");
// And finally, we'll set the speed of the motor!
My question is pretty simple:
I'm now using an additional pin 10, and do a parallel connection (2 routes).
And I simply tested two routes, both work fine. I mean, each route is able to drive 1 single motor.
But, how to code in Arduino, by modifying the code quoted above, to make it work with 2 motors controlled by two pins (pin 9 and pin 10) by already configured 2 routes?
Thank you very much.