Sparki has two wheels that it uses to move around with.
Each of these commands move Sparki in a certain direction. Sparki will continue to drive in that direction until a moveStop command is run.
You can also tell Sparki to move a certain amount with each command. For the moveForward and moveBackward commands, the number is in centimeters. For rotateLeft and rotateRight, it is in degrees. Sparki runs this command until it is done, then performs the next command.
For example, to move forward 20 centimeters and then stop, you would use:
To rotate right 90 degrees and then stop, you would use:
SparkiDuino already has code examples for you to use: File > Examples > Sparki > Wheels Here is one example that shows all the movement commands:
How It Works
Sparki’s two wheels are driven by two geared stepper motors. This special type of motor lets you command Sparki to move a very precise distance.Using the Part
With the basic Sparki code in place, you can move Sparki using these commands:
1 2 3 4 5 6 |
sparki.moveForward(); sparki.moveBackward(); sparki.moveLeft(); sparki.moveRight(); sparki.moveStop(); |
1 |
sparki.moveForward(20); |
To rotate right 90 degrees and then stop, you would use:
1 |
sparki.moveRight(); |
SparkiDuino already has code examples for you to use: File > Examples > Sparki > Wheels Here is one example that shows all the movement commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/******************************************* Basic motor test Move Sparki forward and backwards, then rotate right and left, then stop. Repeat! Can you get Sparki to do any cool motions? Maybe draw something by sticking a pen down the center? ********************************************/ #include <Sparki.h> // include the robot library void setup() { } void loop() { sparki.moveForward();// move the robot forward delay(1000); // wait a second (1000 milliseconds) sparki.moveBackward(); // move the robot backward delay(1000); sparki.moveRight(); // rotate the robot clockwise delay(1000); sparki.moveLeft(); // rotate rhe robot counter-clockwise delay(1000); sparki.moveStop(); // stop all robot wheels delay(2000); // wait two seconds (2000 milliseconds) } |