Servo jitter in "useless box" project

Hey all, I hope someone may be able to lend a hand.

I made this useless box project out of Lego a while back and just found it again the other day. I shelved the project originally because once completed everything worked as was designed except for the constant servo jitter that happens when it is powered on. I would love to have this box sit on my desk at work so that people can walk up and ask "What is this thing?" with it powered on and without it making that annoying servo noise all the time.

Basically I made my own board using an ATTiny85 chip in place of my Arduino. I also included a voltage regulator in there so that I can power it with a 9V battery. Unfortunately I made this thing a while ago (like I said) and really can't remember where I got the guidance for the regulator circuit and honestly I can't remember where I got the guidance for the coding as well. I am a total newbie when it comes to this stuff and am still learning a tiny step at a time (I thought this useless box project would be a good introductory project since it is a pretty simple one to make). I did my best to draw a schematic of the board and I will include the code.

Now i searched around a bit for solutions to servo jitter and the few I have tried have not helped in the least bit. I have a feeling it has something to do with a pull up or pull down resistor. I remember when breadboarding the project I did have another resistor in there somewhere and there was no servo jitter whatsoever. But apparently I forgot to put that resistor in there and have no idea where it was. I did try to put it in a few places with no luck.

I have also tried adding a capacitor across the servo positive and negative terminals...also to no avail.

And last but not least I tried to place a ferrite ring around one twist of the servo signal wire. That also led to no fix as well.

Sorry I don't have any photos of the actual box as it is packed inside another box at the moment. I am in the process of moving next weekend. Once I get settled and unpacked I can post some photos of the completed project.

Like I said I am fairly certain it is a pull up or pull down resistor issue so if anyone has any ideas to what may cause the jitter I would be very thankful for a solution to my problem.

#include <SoftwareServo.h> 

SoftwareServo myservo;                 // create servo object to control a servo 
                                       // a maximum of eight servo objects can be created 

int pos = 0;                           // variable to store the servo position 
int button = 3;                        // The button will be on Pin attiny3

void setup() 
{ 
  myservo.attach(4);                  // attaches the servo to Pin attiny0 
pinMode(pos, OUTPUT);
pinMode(button, INPUT); 
digitalWrite (button, LOW);
} 

void loop() 
{ 
  
      if (digitalRead(button) == HIGH)
  
  for(pos = 100; pos < 185; pos += 180)  // goes from 0 degrees to 90 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    SoftwareServo::refresh();        // must call at least once every 50ms or so to keep your servos updating
                                      // waits 15ms for the servo to reach the position 
  } 
  if (digitalRead(button) ==LOW)
  
  for(pos = 185; pos>=100; pos-=180)     // goes from 90 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    SoftwareServo::refresh();
    delay(50);                       // waits 50ms for the servo to reach the position 
  } 
}


9V block batteries are for smoke alarms and are entirely unsuitable for motors or servos.

You will need a 5-6V power supply capable of supplying one ampere per servo. 4xAA batteries can handle two servos.

Detach the servo after it moves back to the home position. The jitter comes from the control signal being constantly applied to the servo. Most servos shut off the motor when the control signal goes away.

The jitter comes from the control signal being constantly applied to the servo.

That does not happen in my projects, and I never use detach.

My servos do not hold a position if they do not receive a control signal.

jremington:
That does not happen in my projects, and I never use detach.

My servos do not hold a position if they do not receive a control signal.

Really? I've tested a couple different servos with the Arduino library and they always jitter about restlessly when holding a position. What are you doing differently?

jremington:
That does not happen in my projects, and I never use detach.

My servos do not hold a position if they do not receive a control signal.

I never use detach either.

I just ensure all GNDS are tied together.. and I'm of course NOT trying to lift/hold weight not designed for the torque of my servo.

jremington:
9V block batteries are for smoke alarms and are entirely unsuitable for motors or servos.

You will need a 5-6V power supply capable of supplying one ampere per servo. 4xAA batteries can handle two servos.

Oh, I see. Well I will definitely give this a try. I only use a 9V for available space reasons but I think I can move some stuff around and make it work. Thanks!