ServoMotor + PS/2 Mouse

Hi everyone,
i'm trying to control the direction of a servo motor using the 2 buttons of a PS/2 Mouse. What I want is too simple: when the left button is pressed, the position of servo goes to one side, and when the right button is pressed, the position of servo goes to the other side.

I'm trying to use this library: Arduino Playground - Ps2mouse
the first one from the topic (ps2.zip).

The code i wrote is:

#include <ps2.h>
#include <Servo.h> 

PS2 mouse(6, 5);
Servo myservo; 
char mstat;


void mouse_init()
{
  mouse.write(0xff);  // reset
  mouse.read();  // ack byte
  mouse.read();  // blank */
  mouse.read();  // blank */
  mouse.write(0xf0);  // remote mode
  mouse.read();  // ack
  delayMicroseconds(100);
}

void setup()
{

  Serial.begin(9600);
  mouse_init();
  myservo.attach(10);
}


void loop()
{
  mouse.write(0xeb);  // give me data!
  mouse.read();      // ignore ack
  mstat = mouse.read();
  Serial.println(mstat, BIN);
  if (mstat == 1001, BIN){
   myservo.write(180); 
  }
  if (mstat == 1010, BIN){
   myservo.write(0); 
  }
}

I used the values 1001 and 1010 for mstat because i saw that values in the monitor serial, when i press the buttons.

But, it doesn't works!

Can you help me?

When you printed mstat with the BIN flag, it printed the binary representation of the number for you.

You are now trying to compare the value to 1001 and 1010 in decimal, so, of course they don't match.

0b1001 = 9
0b1010 = 10

OK... thanks..it worked finaly.
I was thinking that if i placed "1001 ,BIN" the program should test the value in binary mode. But ok, i changed the 1001 for 9 and worked. Thank you again.