what's the problem?

hi guys…
I apologize in advance for my bad english
I just bought my “Arduino uno board”…yesterday i played with this amazing microcontroller…
now i wrote a code:

#include <Servo.h>                  // includo la libreria sui servi
Servo s;                            // definisco un tipo servo di nome s           
void setup() {
  Serial.begin(9600);               // inizializzo la comunicazione con il pc
  pinMode(8, INPUT);                // setto il pin 8 come input
  pinMode(9, INPUT);                // setto il pin 9 come input
  s.attach(2);                      // attacco il servo al pin 2
  s.write(0);                       // setto un angolo iniziale del servo pari a zero
  delay(2000);                      //attendo 2 secondi
}  
void loop() { 
  int butt1 = digitalRead(8);       // butt1= valore sul pin 8      
  int butt2 = digitalRead(9);       // butt2= valore sul pin 9  
  if(butt1 == HIGH){                // se premo butt1 (quando premo scorrono i 5V)
    s.write(90);                     // porto il servo a 90° 
    delay(3000);
    Serial.println("prenuto 1");    // stampo a video che ho premuto butt1
  }
  if(butt2 == HIGH){                // se premo butt2
    s.write(0);                     // porto il servo a 0°                    
    delay(3000);
    Serial.println("premuto 2");    // stampo a video che ho premuto butt2
  }
  delay(10);
}

what i would do is:
when i push butt1 → servo go in position 90° and in serial monitor: “premuto1”
when i push butt2 → sero go in position 0° and in serial monitor: “premuto2”
it’s simple but it doesn’t work.
if i don’t connect my servo in my circuit i can see in my serial monitor “premuto 1” when i push butt1 and “premuto 2” when i push butt2, but if my servo is connect to my circuit nothing appears in my derial monitor and my circuit doesn’t work.
here a conceptual scheme:

Anybody know what is the problem?

thanks in advance…

I don't see any scheme.
I suppose we must see a picture there?

Regards,

Atmoz

[edit]

I think you mean this: http://imageshack.us/photo/my-images/854/dscf2004ik.jpg
But in your code you have a "/" to much at the end...

[edit2]

How much milliampere must the servo have to work?
I think you can't connect it directly to your Arduino, because it can only source 40mA per output!!
And the most servo's use much more then that!!

Did you connect the grounds together?

this is the servo that i'm using:
http://www.maxfordusa.com/hs-9g-blue.aspx
this is a foto of my circuit:

i'm using a breadboard which is powered by my arduino board, so, i think that all grounds are connected together...

But in your code you have a "/" to much at the end...

where??

Try this for the switches:
Use internal pullups, change the logic to look for a Low instead of a High.
Also try rotating the buttons 1/4 turn, often times pin 1/3 & 2/4 are wired together, or 1/2 & 3/4.
Use a multimeter to confirm which you have.

  pinMode(8, INPUT);                // setto il pin 8 come input
digitalWrite ( 8, HIGH);           // enable internal pullup resistor  <<<<<<
  pinMode(9, INPUT);                // setto il pin 9 come input
digitalWrite ( 9, HIGH);           // enable internal pullup resistor <<<<<<

  int butt1 = digitalRead(8);       // butt1= valore sul pin 8      
  int butt2 = digitalRead(9);       // butt2= valore sul pin 9  
  if(butt1 == LOW){                // se premo butt1 (quando premo scorrono i 5V)   <<<<<<<<<<<<<<<<<<<
    s.write(90);                     // porto il servo a 90° 
    delay(3000);
    Serial.println("prenuto 1");    // stampo a video che ho premuto butt1
  }
  if(butt2 == LOW){                // se premo butt2                    <<<<<<<<<<<<<

And wire them like this instead:

@CrossRoads
i tried to do as you suggested, but still doesn’t wok…
when i push butt1 the servo go to 90° but as soon as return to last position…like an impulse… :~ :~
so, when i push butt2 nothing appens because the servo is alrady in 0°.
So i changed my sketch:

#include <Servo.h>                  // includo la libreria sui servi
Servo s;                            // definisco un tipo servo di nome s           
void setup() {
  Serial.begin(9600);               // inizializzo la comunicazione con il pc
  pinMode(8, INPUT);                // setto il pin 8 come input
  digitalWrite( 8, HIGH);
  pinMode(9, INPUT);                // setto il pin 9 come input
  digitalWrite(9, HIGH);
  s.attach(2);                      // attacco il servo al pin 2
  s.write(45,);                       // setto un angolo iniziale del servo pari a zero <<<<<<<<<<
  delay(2000);                      //attendo 2 secondi
}  
void loop() { 
  int butt1 = digitalRead(8);       // butt1= valore sul pin 8      
  int butt2 = digitalRead(9);       // butt2= valore sul pin 9  
  if(butt1 == LOW){                // se premo butt1 (quando premo scorrono i 5V)
    s.write(90);                     // porto il servo a 90° 
    delay(1500);
    Serial.println("prenuto 1");    // stampo a video che ho premuto butt1
  }
  if(butt2 == LOW){                // se premo butt2
    s.write(0);                     // porto il servo a 0°                    
    delay(1500);
    Serial.println("premuto 2");    // stampo a video che ho premuto butt2
  }
  delay(10);
}

i setted start position of my servo to 45°.
In this way when i push butt1 the servo go to 90°but return to 45°
instead when i push butt2 servo go to 0° but return as soon as to 45°
I don’t understand this strange behavior…

Sounds like it could be a reset.
How are you powering all this?
Put a debug print in setup

all this is powered by usb cable...

Put a debug print in setup

what does this means?can you explain?

Put a print in setup, if it repeats, you've got an unexpected reset.

I must add a "print" in "void setup" in my sketch? What should I print? Can you give me an example? I'm sorry, but I'm not an expert ...

It doesn't matter what you print, just something that is printed nowhere else in the sketch.
You already have prints, so you don't need an example.

rizzof87:
I must add a "print" in "void setup" in my sketch? What should I print? Can you give me an example? I'm sorry, but I'm not an expert ...

void setup() {
  Serial.begin(9600);               // inizializzo la comunicazione con il pc
  Serial.println ("In Setup"); 

...  and now the other stuff

}