Update! I answered my own question....I found that this motor controller has a max PWM of 127 not 255. Once I changed that, I was okay!
HI Guys,
I recently bought 2 Pololu Qik 2s9v1 Motor Controllers. I"ve tested both out in demo mode and they work. So, I wrote some code to have my Arduino robot Herbert run forward and reverse but I don't think I understand the Pololu library for the motor controller and Arduino. I studied their documentation and looked at their example code, but their example code is for sending commands via serial input...I don't want that. So what I did was take their example code which is downloadable here: http://code.google.com/p/qik2s9v1arduino/ then I commented out and deleted the stuff I didn't think was necessary. I then put in some PWM numbers (255), some delays and.....nothing. The motors are doing anything.
Anyone have experience with these controller boards? This was just testing one board and two motors...In the end I will need to control 4 motors with 2 boards....but one step at a time. Once I can control 2 motors with one board I will be happy for today, lol...
Here's my messed up sample code:
/*Testing the Pololu library to see if I can get the motors controlled
I'm shooting for a test that will have Herbert move forward, backward, etc*/
#include <CompactQik2s9v1.h>
#include <NewSoftSerial.h>
/*
Important Note:
The rxPin goes to the Qik's "TX" pin
The txPin goes to the Qik's "RX" pin
*/
#define rxPin 3
#define txPin 4
#define rstPin 5
NewSoftSerial mySerial = NewSoftSerial(rxPin, txPin);
CompactQik2s9v1 motor = CompactQik2s9v1(&mySerial,rstPin);
byte motorSelection;
byte motorSpeed;
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
motor.begin();
motor.stopBothMotors();
}
void loop()
{
motorSelection = Serial.read();
motor.motor0Forward(255);
motor.motor1Forward(255);
delay(4000);
motor.motor0Coast();
motor.motor1Coast();
delay(2000);
motor.motor0Reverse(255);
motor.motor1Reverse(255);
delay(4000);
}
//byte getSpeedByte()
//{
// return Serial.read();
//}
//void showHelp()
//{
// Serial.println("Send 1 or 2 bytes: ");
// Serial.println("<motor selection> (<speed>)");
// Serial.println("motor selection choices:");
// Serial.println("0 - m0 forward");
// Serial.println("1 - m0 reverse");
// Serial.println("2 - m1 forward");
// Serial.println("3 - m1 reverse");
// Serial.println("4 - m0 coast (no speed byte)");
// Serial.println("5 - m1 coast (no speed byte)");
// Serial.println("6 - stop both (no speed byte)");
//}
Thanks for the help!
Annie