Sparki has a crook in it's neck


I am not sure why or how, but the sparki servo is no longer centering correctly.

It was initially, but ever since trying to get Robo Realm to work (which my little boy and I eventually got working - impressive radar display!), and then trying to load the default program back on, it seems that Sparki loves jamming his head to the left regardless of what we tell it to do.

We tried uploading the servo example, and when executing that program, it briefly cricks it’s neck to a left 45^ position at most, and then back all the way to the left (with a jammy servo sound - like it wants to go further than -90).

Is there some default factory loaded offset value that got messed up? I’m not a coder, but from digging around it looks like the initial offset is on the EEPROM perhaps? Not sure what to do to fix this, but we didn’t get much play time in before this issue.

Basically it seems like SERVO_LEFT<-90, SERVO_CENTER=-90, and SERVO_RIGHT=-45 or thereabouts.

In sum, HELP!? My poor sparki has whiplash. Reset button didn’t seem to help either.


Had the same problem. The RANGE FINDER head is out of position, meaning SERVO_CENTER is actually not in the “0” center position in your case “-90”. The fix I did was to command the servo to SERVO_CENTER “0”, turn power off on Sparki, and then un-screw and repostion the RANGE FINDER head to face the front “0” position.Screw back the RANGE FINDER head and now works as commanded.


Thanks ortsac.

I did as you suggested, and sparki’s head now faces forward so great! Unfortunately, the range of motion is still comprimised.

Thinking something was messed up with the servo, I replaced it with one of the servos from my unassembled hexy kit.

Same issue! I don’t know what is going on.

Basically, a -90 is actually about a -5, a 0 is also a -5, and 90 is about 40 at most.

I spoke with Arcbotics via chat, and they’re also clueless. Don’t know what to do at this point.

So odd that replacing the servo presented the same issue, and according to arcbotics, the only thing in the EEPROM is a single initial offset.

Any other ideas as to how I can correct this?


Same issue here.


I have the EXACT same issue after trying the Roborealm software. I’ll try your fix and see if I can “get Sparki’s head straight.” I was worried, because I thought it might be a hardware issue!!

Thanks for the tip!


I do not use Roborealm software, just the straight Windows installation, but after realigning the RANGE_FINDER head to SERVO_CENTER I no longer have an issue with the servo scanning between -90 degrees and +90 degrees. So the problem you are experiencing with the servo could be associated with Roborealm.


I can’t get this issue to go away. I’ve tried ortsac’s suggested fix, but I still have the same issue. When I try to run this code that zero’s out the servo, funny things happen:

 Basic Servo test
 Move the servo on Sparki's head. The servo
 can rotate from -90 to 90 degrees. -90 is 
 facing left, 0 is facing forward,  and 90
 is facing right.
#include <Sparki.h> // include the sparki library

void setup()
void loop() 

  sparki.servo(0); // rotate the servo to is 0 degree postion (forward)
  sparki.println("Servo 0");
  sparki.servo(-80); // rotate the servo to is 0 degree postion (forward)
  sparki.println("Servo -80");
  sparki.servo(0); // rotate the servo to is 0 degree postion (forward)
  sparki.println("Servo 0");
  sparki.servo(80); // rotate the servo to is 0 degree postion (forward)
  sparki.println("Servo 80");
  sparki.servo(0); // rotate the servo to is 0 degree postion (forward)
  sparki.println("Servo 0");

Sparki Library used: Sparki.Driver-
Sparki.h modified date: 20140218 @ 17:00
Sparki.cpp modified date: 20140218 @ 17:00
Computer OS: Windows 7 Pro x64

Here is a link to a video (mp4) of what happens when I run the code: … 58dfd467ff

Any ideas how to fix this?


I uploaded your sample code. I do not have the problem as you have captured on your video on my Sparki. It performs as programmed. Your problem could be the controller board, or cable, or the servo itself.

Operating Environment
Sparki Library used: Sparki.Driver-
Sparki.h modified date: 20140217 @ 09:20
Sparki.cpp modified date: 20140217 @ 09:23
Computer OS: Windows 7
Notes: Roborealm not used.


My Sparki had a crook also. I am not at home so don’t have my source, but I set a couple variables that offer me a custom servoCenter, servoLeft, and servoRight variable where center is hard adjusted to -2 and right and left are not -90 or 90, and are more like 75 and -80. These are giving me exact 90 degree rotation of the neck to front, direct left and direct right.

This was out of the box with no software modifications like roborealm or updates. So I would attribute the issue to servo setup/access/calibration of some sort.

(Not to mention he no longer hits his head on the LCD)


For some reason, the audio got corrupted when I converted the video to mp4. Here is the original .mov version:


Add me to the crook in the neck club. My 0 position was beyond -90, it was hitting the LCD. I tried the mechanical fix of unscrewing the the range finder and moving it but it still isn’t right.

Using the code below I find that it only moves from the 90 degree setting(physically ~60) to 30 degree setting(physically 0). At 40 you can hear the motor straining, everything from 30 to -90 stays still although you can hear the motor change pitch.

[code]#include <Sparki.h>

void setup()
void loop()
sparki.println(" 0");
for( int i= 90; i>-90; i=i-10)
sparki.print(" ");

I just looked into sparki.cpp and did some more experimenting and I was surprised to find that sparki.servo() is not software limited to -90 through 90. My full range of motion is currently about 40 through 210. I removed the rangefinder entirely, so it would not hit the LCD, to find the range. You can hear the motor straining as it reaches it’s limits. By repositioning the range finder and using a servo offset variable at least you can continue to work with Sparki.

Any help Arcbotics? It would be nice to be able to reset the servo range and have this working normally but I assume it is a mechanical problem and not an easy fix.


I think I have the same/similar problem. I just got my Sparki and have not downloaded any software or connected Sparki to anything yet. When I use the remote buttons 4 or 6, the range finder tries to move so far to the left or right that it hits the LCD while the motor keeps running. I have to hit remote button 5 to get it to stop.


I have the same problem. After uploading the Roborealm Sparki sketch, the servo immediately pinned itself to the left. Now no matter what I’ve tried, I can’t get the servo to work correctly. It does what’s shown in the video. This happens regardless of the arcbotics software version, and on another computer that never had Roborealm installed.


I finally had a chance to load the video, and the behavior is exactly the same for me. (the OP)

There may be mulitple issues being discussed, but my issues started after uploading the Roborealm fix and were not fixed thereafter even after a complete redownload of Sparkiduino, and multiple resets. I am no longer using Roborealms replacement C file, but the problem will not go away. It’s as if something was zeroed out on a hardware level. I know this because the unit worked absolutely perfectly just prior to installing Roborealm and getting it up and running on Sparki.

I even replaced (under guidance from Arcbotics) the servo motor (using one from Hexy), and still no dice.

I hope that helps someone troubleshoot this, because I am not using my Sparki at all until it is working correctly.

Interestingly, when walked through mapping and addressing the servo directly on an arduino level, we could get it to rotate well again. It’s the sparki software and sparki servo commands that cause the misbehavior.


I’m wondering if someone messed with the EEPROM, putting a massive offset in the servo.

Can you guys run this code, and see if it that works? It should look left, forward, then right, then repeat. Its the essentials of the servo software in sparki.cpp, except with no offsets from the EEPROM.

volatile int8_t servo_deg_offset = 0;

void setup() // code inside these brackets runs first, and only once

void loop() // code inside these brackets runs over and over forever

void startServoTimer(){
  char oldSREG = SREG;				
  noInterrupts();                                       // Disable interrupts for 16 bit register access
  TCCR1A = 0;                                           // clear control register A 
  TCCR1B = _BV(WGM13);                                  // set mode 8: phase and frequency correct pwm, stop the timer
  ICR1 = 20000;                                         // ICR1 is TOP in p & f correct pwm mode
  TCCR1B &= ~(_BV(CS10) | _BV(CS11) | _BV(CS12));
  TCCR1B |= 0x02;                                       // reset clock select register, and starts the clock
  DDRB |= _BV(PORTB1);                                  // sets data direction register for pwm output pin
  TCCR1A |= _BV(COM1A1);                                // activates the output pin
  interrupts();                                         // re-enable interrupts
  SREG = oldSREG;

void servo(int deg)
  int duty = int((((float(-deg+servo_deg_offset)*2000/180)+1500)/20000)*1024); // compute the duty cycle for the servo
  //0 = 26
  //180 = 128
  unsigned long dutyCycle = 20000;
  dutyCycle *= duty;
  dutyCycle >>= 10;
  char oldSREG = SREG;
  OCR1A = dutyCycle;
  SREG = oldSREG;


Ran the suggested sketch…on my unit, the range- finder shell hits both sides of the LCD as it goes to either -90 or 90 degrees with the motor still running as it touches the LCD screen.

Using the sketch you provided, the perfect angles for my Sparki are: -86 degrees for the left and 83 degrees for the right. With these angles, the ranger finder is parallel to the left and right sides of the unit without touching the LCD.


Pretty much the same results as ortsac, except my range without hitting the LCD or hearing the servo strain is -83 to 85.

Without this code, using the standard sparki.servo(), my range is about 50 to 210 with a center at 130.


I also have this problem, brand new sparki. I have only used the remote so far, just opened it. I noticed that when the “head” is triggered to turn, there is no endstop so the servo keeps on trying to turn. I wonder if this has caused slippage somewhere. I expect if there were a stop switch or a defined end to the amount of turn to prevent it form “bottoming out”, the centre point would not be thrown off so easily.


Folks, while there is by default an issue with the servos grinding and/or hitting LCD, there is a very easy fix.

Open Sparki.h in a text editor.

Here’s the first few lines of code from the file:

[code]#ifndef Sparki_h
#define Sparki_h

#include “Arduino.h”
#include “Print.h”

#define STATUS_LED 13
#define BUZZER 11 // PB7
#define ULTRASONIC_ECHO 5 // PC6
#define ULTRASONIC_TRIG 10 // PB6
#define IR_RECEIVE 7 // PE6
#define IR_SEND 6 // PD7

#define SERVO 9 //
#define SERVO_LEFT -90
#define SERVO_CENTER 0
#define SERVO_RIGHT 90

Simply change the #define SERVO_LEFT & #define SERVO_RIGHT values to less than -90 & +90 respectively.

Hope this helps.


As a result of this post, we’re now profiling a random sample of servos to see what values best represent left and right without hitting the sides. I’ll update the code as we learn this value. 85/85 sounds like a better place to start for now, so I’ll update it to that in the mean time.