Make 2 buttons turn continuous servo clockwise and counter and clockwise

the servo is only moving clockwise what is wrong with this code?

sketch_may25b.ino (1.69 KB)

    pinMode (buttonPinCW, INPUT); // sets button as input
    pinMode (buttonPinCC, INPUT); // sets button as input

But nothing to turn the internal pullup resistors on. So, you are using external resistors, right? How ARE the switches wired?

Look at the state change detection example. You want to move the servo when the switch BECOMES pressed, not when the switch IS pressed. Or, so it seems to me.

When slowFocusPull() is called with 0, it returns 45. When called with 180, it returns 45, too. Is that really what you intended?

Simple two button servo code.

//zoomkat servo button test 12-29-2011
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }    
  
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
}