Need Help with this code

I wrote this as an experiment to see how to plot words. My hope was to get the entire alphabet upper and lower case in a library to recall so you could print anything. the problem is that I can not get it to tell the sparki to turn right. Just a heads up the “float multi” is the offset so the angles are correct as the last fix did not fix this problem. here is the code.

#include <Sparki.h> // include the sparki library

void setup() {
sparki.servo(SERVO_CENTER); // center the servo
}
//This should write the word Colton
//there is some problem at the letter n
//the moveRight(A) turns left
//does anyone have any idea why?

float n = .5; // distance to travel
float multi = 1.066; // correction for sparki angles
int a = 90; // angle to turn
float A = a * multi;
int b = 180;
float B = (a + b) * multi;

void loop() {
sparki.clearLCD(); // wipe the screen

// write the measurements to the screen
sparki.println(n);
sparki.println(a*multi);

      sparki.moveForward(2); //draw Capitol C
      sparki.moveLeft(A);
      sparki.moveForward(4);
      sparki.moveLeft(A);
      sparki.moveForward(6); 
      sparki.moveLeft(A); 
      sparki.moveForward(6); 
      sparki.moveForward(2); //draw o 
      sparki.moveLeft(A);   
      sparki.moveForward(2); 
      sparki.moveLeft(A);
      sparki.moveForward(2); 
      sparki.moveLeft(A);
      sparki.moveForward(2); 
      sparki.moveLeft(A);
      sparki.moveForward(4);          
      sparki.moveLeft(A);  //draw l
      sparki.moveForward(6);
      sparki.moveBackward(6);
      sparki.moveLeft(B);          
      sparki.moveForward(3);
      sparki.moveLeft(A);  //draw t
      sparki.moveForward(6);
      sparki.moveBackward(2);
      sparki.moveLeft(A);          
      sparki.moveForward(2);
      sparki.moveBackward(4);
      sparki.moveForward(2);          
      sparki.moveLeft(A);
      sparki.moveForward(4);
      sparki.moveLeft(A);          
      sparki.moveForward(2);
      sparki.moveForward(2); //draw o 
      sparki.moveLeft(A);   
      sparki.moveForward(2); 
      sparki.moveLeft(A);
      sparki.moveForward(2); 
      sparki.moveLeft(A);
      sparki.moveForward(2); 
      sparki.moveLeft(A);
      sparki.moveForward(4);
      sparki.moveLeft(A); //draw n          
      sparki.moveForward(2);
      sparki.moveRight(A); //problem starts here
      sparki.moveForward(2);
      sparki.moveRight(A);
      sparki.moveForward(2);
      sparki.moveLeft(A);
      sparki.moveForward(6);          

sparki.updateLCD(); // display all of the information written to the screen

// n = n + 2; // adds 2 to the value of n (not used)
delay(10000); // wait 1 second

}

Need help please. I thing this should work.

OK, that appears to be a bit too much to get through. this is just the “n” it instead draws and “o” because the “sparki.moveRight (A);” has the sparki turn left. what is up?

#include <Sparki.h> // include the sparki library

void setup() {
sparki.servo(SERVO_CENTER); // center the servo
}
float n = .5; // distance to travel
float multi = 1.066; // correction for sparki angles
float a = 90; // angle to turn
float A = a * multi;
void loop() {

//this should draw a line that looks like this I–I___
sparki.moveForward(2);
sparki.moveLeft(A); //draw n
sparki.moveForward(2);
sparki.moveRight(A);
sparki.moveForward(2);
sparki.moveRight(A);
sparki.moveForward(2);
sparki.moveLeft(A);
sparki.moveForward(6);

delay(10000); // wait 0.1 seconds

}

sorry, I do not know how to insert code. if some one would tell me how to do that it would also help. thanks

Just tag it like this:


Put your source code here!

Sparki will not turn right. I finally dummied it down to this and the little shit still goes left. any ideas?

#include <Sparki.h> // include the sparki library

void setup(){ 
  sparki.servo(SERVO_CENTER); // center the servo  
}
  int n = 5;                 // distance to travel
float multi = 1.066; // correction for sparki angles
float a = 90;            // angle to turn (this is the outside angle)
void loop() {
       
        


            sparki.moveForward(n); // go forward 5 centimeters

            sparki.moveLeft(a*multi); // rotate right 90 degrees

  delay(100); // wait 0.1 seconds
}

I uploaded the shorter version of your code. I have the same problem. The issue is in the “Sparki.cpp” code. It has an error when an argument is used in the “moveRight” command, it call the “moveLeft” function when an argument is present. Here’s the original code in “Sparki.cpp” for the “moveRight” function: (notice that a “moveLeft” is called after “else” statement with the argument “turn” is used as a delay.)

Original Sparki.cpp code:

void SparkiClass::moveRight(float deg)
{
  float turn = 21.388888*deg;
  if( (deg == -1) || (deg == 0) ){
      moveRight();
  }
  else{
      moveLeft();
      delay(long(turn));
      moveStop();
  }
}

Here’s what I modified to make it move in the correct direction when an argument is used:

void SparkiClass::moveRight(float deg)
{
  float turn = 21.388888*deg;
  if( (deg == -1) || (deg == 0) ){
      moveRight();
  }
  else{
//      moveLeft();    original code
      moveRight();      // modified
      delay(long(turn));
      moveStop();
  }
}

We’ve posted an update that fixes this. Go ahead and re-download and re-install, and this problem will be fixed: