Problem with Qik2s12V10 and Arduino!

Dear friends,

I recently bought Qik2s12V10 and i tried to control the Dc motor with the help of the Ping sensor but its not working. My ping sensor is working perfectly but My motor doesn’t move in any direction. I also checked if the motor was broken by applying direct Dv voltage then it works but it doesn’t respond to the code which i wrote in my Arduino Uno revision 3. here is the code which i have written.

#include <CompactQik2s9v1.h>
#include <SoftwareSerial.h>

#define rxPin 2   //connect the rxPin of Qik2s12v10 to pin 2 of the Arduino
#define txPin 3  //connect the txPin of Qik2s12v10 to pin 3 of the Arduino
#define rstPin 4 //connect the rstPin of Qik2s12v10 to pin 4 of the Arduino

const int pingPin=7; // connect the ping pin to pin 7 of the Arduino

SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
CompactQik2s9v1 motor = CompactQik2s9v1(&mySerial,rstPin);

void setup() {

  motor.stopBothMotors(); //Stops both the motors

void loop() {
  int duration, cm;
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  digitalWrite(pingPin, HIGH);
  digitalWrite(pingPin, LOW);
  pinMode(pingPin, INPUT);
  duration = pulseIn(pingPin, HIGH);
  cm=microsecondsToCentimeters(duration); // calculating centimeter for the ping sensor
  delay (100);

  if(cm <= 8)
    motor.motor0Reverse(127); //Rotates Motor0 in reverse direction
    motor.motor1Reverse(127);  ////Rotates Motor1 in reverse direction
    motor.motor0Forward(127); //Rotates Motor0 in forward direction
    motor.motor1Forward(127); //Rotates Motor1 in forward direction
  Serial.print("Centimeter ");

long microsecondsToCentimeters(long microseconds)
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;

Do suggest me if i am missing something in my code or if i am doing something wrong there.

Any help or suggestion will be highly appreciated.

Regards, Milan

Hello, Milan.

I put your program in code tags to make it easier to read. I have not looked at it too closely, but from your comments, I think you are not connecting the qik correctly:

#define rxPin 2   //connect the rxPin of Qik2s12v10 to pin 2 of the Arduino
#define txPin 3  //connect the txPin of Qik2s12v10 to pin 3 of the Arduino

rxPin and txPin are labeled from the perspective of the Arduino, not the qik. You should connect the Arduino’s receive pin (2) to the qik’s transmit pin (TX) and vice versa (3 to RX), so your serial connections are reversed if you made them according to what you wrote in your comments.

If that does not solve your problem, please try to simplify your program by taking out all of the code for the Ping sensor and just try to make a simple program that drives the motors. Please note that the CompactQik2s9v1 library was written for the qik 2s9v1, which is different from 2s12v10, although the commands between the two versions are similar enough that I would expect the library to work for you in this case.

- Kevin

thanks a loot that helped!!

cheers :smiley: , Milan

hi Kevin,

I got one more question for you? is it possible to connect TWO qik2s12v10 with Arduino Uno and control FOUR Dc Motors independently? Can i use the Pin no. 2 and 3 from from Arduino for both qik2s12v10 or i need to connect it to the different pins?

Please do suggest me.



In general, it should be possible to control two qiks with a single Arduino. If you wrote your own software to communicate with the qiks using the Pololu protocol (see Section 4.c of the user’s guide), you would be able to daisy-chain both qiks on the same serial interface.

However, the CompactQik2s9v1 library only supports the compact protocol, which does not allow daisy-chaining. In theory, you could still use the library to control two qiks by having two CompactQik2s9v1 objects and putting each qik on a different set of pins, although you might have some difficulties getting this working (especially if you need to read data from both qiks, as only one SoftwareSerial can be listening at a time).

- Kevin