I know this maybe to much to ask but has anyone figured out what the conversion is from the value for a Sparki.moveRight comand to accual degrees. What I get is turning 175 gets me about a 90 +_deg turn to the right. Also moveForward 20 actually moves the Sparki about 8 cm. I can just keep playing with this but I thought the steppers might step a certain number of degrees each step. Anyone? my grandson has a plan to draw an equal lateral triangle. It sounds easy but 3 adjustments and we have not nailed it yet. We originally thought that entering Sparki.move Forward (20); would move the Sparki 20 cm, not so and spark.moveRight 300 would turn us 60 deg, no so. It looks like it is about a value of 240 will turn us the 120 degrees we need. Why the double value?
WELL BY TRIAL AND ERROR sparki.moveRight (235) turns my Sparki 120 deg. We finally got a near perfect equal lateral triangle. Here is the code we used.
#include <Sparki.h> // include the sparki library
void setup()
{
}
int n = 20; // declares variable n as interger
void loop() {
sparki.clearLCD(); // wipe the screen
float x = sparki.magX(); // measure the Magnetometer x-axis
float y = sparki.magY(); // measure the Magnetometer y-axis
float z = sparki.magZ(); // measure the Magnetometer z-axis
// write the measurements to the screen
sparki.print("Mag X: ");
sparki.println(x);
sparki.print("Mag Y: ");
sparki.println(y);
sparki.print("Mag Z: ");
sparki.println(z);
sparki.print("Value n: ");
sparki.println(n);
sparki.RGB(100,0,0); // turn the light red
sparki.beep(); // beep!
sparki.moveForward(n); // go forward 8.5 centimeters
sparki.RGB(0,0,100); // turn the light blue
sparki.moveRight(232); // rotate right 120 degrees
sparki.updateLCD(); // display all of the information written to the screen
delay(100); // wait 0.1 seconds
}
Curious. I looked into it & observed the following:
in sparki.h, the following is declared for Sparki’s dimensions:
[ul]// properties about the robot in cm
#define PI 3.14159
const float WHEEL_DIAMETER_CM = 5.15;
const float WHEEL_CIRCUMFERENCE_CM = WHEEL_DIAMETER_CM * PI;
const float TRACK_WIDTH = 11.1; //tyre seperation in cm
//const float WHEEL_TRAVEL_PER_360 = WHEEL_TRACK * PI; // cm per ROBOT revolution
const int STEPS_PER_REV = 8192; // steps for wheels to revolve 360 degrees
const float STEPS_PER_CM = STEPS_PER_REV / WHEEL_CIRCUMFERENCE_CM; // linear movement
const float STEPS_PER_ROTATION = (TRACK_WIDTH / WHEEL_DIAMETER_CM) * STEPS_PER_REV ; // robot rotation
const float STEPS_PER_DEGREE = STEPS_PER_ROTATION / 360.0; // robot rotation
const float CM_PER_DEGREE = WHEEL_CIRCUMFERENCE_CM / 360.0; // wheel movement per degree rotation of robot
// circumference = 16.18
[/ul]
And in sparki.cpp, the following definitions are stated:
[ul]void SparkiClass::moveRight(float deg)
{
float turn = 21.388888*deg;
moveRight();
delay(long(turn));
moveStop();
}
void SparkiClass::moveRight()
{
motorRotate(MOTOR_LEFT, DIR_CCW, 100);
motorRotate(MOTOR_RIGHT, DIR_CCW, 100);
}
void SparkiClass::moveLeft(float deg)
{
float turn = 21.388888*deg;
moveLeft();
delay(long(turn));
moveStop();
}
void SparkiClass::moveLeft()
{
motorRotate(MOTOR_LEFT, DIR_CW, 100);
motorRotate(MOTOR_RIGHT, DIR_CW, 100);
}
[/ul]
If you place a multiplier of 2 in front of the float for turns, it corrects the calculation for what Rwardjr5 is trying to do.
ie-> [ul]void SparkiClass::moveRight(float deg)
{
float turn = 221.388888deg;
moveRight();
delay(long(turn));
moveStop();
}
[/ul]
No idea where the 21.388888 comes from. I’m after recking my head with a calculator
& can’t figure it out. Anyone able to explain the numbers?
ps-> Guess the distance travelled could be corrected too by adding multiplier before this:
[ul]void SparkiClass::moveForward(float cm)
{
float run = 222.222222*cm;
moveForward();
delay(run);
moveStop();
}
[/ul]
Again, no idea where the 222.22222 comes from 
The comments in the examples indicate that parameters are supposed to represent centimeters an degrees. I think this is excellent because these are units that should be familiar to the target audience.
Is it possible to have this fixed quickly as it will break code that people are writing now.
I agree, hope this gets fixed quickly; I can imagine lots of broken code when distances and angles all change meaning!