Continuing the discussion from Arduino Motor Controller Pin #10 Remap?:
Thanks to AmandaS, I was able to make my MicroMaestro work with the USB 2.0 Host Shield. Now I want to add the MC33926 Dual Motor Shield into the mix. The USB shield uses pins d9-13, so I had to remap d9, d10, and d12 on the MC33926 shield.
First question, are pins d5 and d6 (timer0) the only option I have for remapping these pwm pins, since timer2 uses pin d11 and that is out too? Or can I map them to analog pins as well?
Second question, if I remap those pins, for example, to d5,6, would changing the library to work with timer0 be difficult? I have no idea how to begin such an undertaking. When it comes to programming, I am pretty much “a cut and paste what I find on the web” luddite. Any examples or references for doing this?
Third question, if I should avoid using the library, then all I have to do is use “pinMode” to define the motor channel, and “digitalWrite” to drive it high or low, as in this example?
For reference, below is the code I have working now, without the USB host shield attached. Bascially, I just want to be able to run this code with the d9, 10, and 12 pins from the dual motor shield remapped, e.g. d9 -> d5, d10 -> d6, d12->d3.
#include "DualMC33926MotorShield.h"
#include <SoftwareSerial.h>
DualMC33926MotorShield md;
const int buttonPinW = 2; // the pin number of the pushbutton
int buttonStateW = 0; // variable for reading the pushbutton status
boolean startW = true; // use these to add a delay after pushing button
void setup() {
// initialize the pushbutton pin as an input:
pinMode(buttonPinW, INPUT);
Serial.begin(9600);
md.init();
}
void loop(){
// read the state of the pushbutton value:
buttonStateW = digitalRead(buttonPinW);
int speed =0;
md.setM1Speed(speed);
md.setM2Speed(speed);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonStateW == HIGH) {
if(startW == true){
delay(3000);
}
startW = false;
md.setM1Speed(-156);
md.setM2Speed(-150);
Serial.println(" driving ");
Serial.println(" White ON ");
delay(250);
}
}
Thanks for any help,
Mike