Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Having a problem with my code


#1

hello all,
ive got an arduino uno board using a pololu qik 2s9v1 motor controller, i was hoping that somebody could possibly help fix this code. basically all i need this robot to do is complete a simple track. thanks for any incoming help.

                                                                 Tom

[code]#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(” ()”);
// 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)”);
//}[/code]


#2

Hello.

What is wrong with it?

- Jeremy


#3

It won’t compile in the arduino software and I cannot figure out why, all I need to do is drive two motors, any help is much appreciated. Or if you have a program that would work much better


#4

What errors are you getting when you try to compile the program? Also, please refer to Read Before You Post: General Advice for Getting Help for posting questions about code.

- Jeremy