Skip to content

Instantly share code, notes, and snippets.

@mithi
Last active Aug 29, 2015
Embed
What would you like to do?
Sparki Neck Servo Test
#include <Sparki.h>
void beepx(int x, int d){
for (int i = 0; i < x; i++){
delay(d);
sparki.beep();
}
}
void servoLeftToRight(int degree, int d){
for (int angle = -90; angle < 90; angle += degree){
sparki.servo(angle);
delay(d);
}
}
void servoRightToLeft(int degree, int d){
for (int angle = 90; angle > -90; angle -= degree){
sparki.servo(angle);
delay(d);
}
}
void servoNodsNo(int xTimes, int d){
for (int x = 0; x < xTimes; x++){
sparki.servo(-90);
delay(d);
sparki.servo(90);
delay(d);
}
}
void servoNodsNoTest(){
for (int interval = 1000; interval > 0; interval -= 200){
servoNodsNo(4, interval);
beepx(1, 200);
}
}
void servoTest(){
servoNodsNoTest();
servoLeftToRight(45, 1000);
servoRightToLeft(45, 1000);
}
void setup(){
servoTest();
}
void loop(){
servoLeftToRight(45, 1000);
servoRightToLeft(45, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment