Leaderboard


Popular Content

Showing content with the highest reputation on 05/08/2015 in Posts

  1. 1 point
    @Sid, From playing with my, albeit broken, case, I believe the o-rings go between the bottom later and the board to keep any PTH pins from getting bent.
  2. 1 point
    Jack I have used the standard Arduino PS2 library which I found here: http://playground.arduino.cc/ComponentLib/Ps2mouse The link to download the library is http://playground.arduino.cc/uploads/ComponentLib/ps2.zip Please note - that in the header file ps2.h you have to change WProgram.h" with "Arduino.h". I put the mouse into PS2/A and the keyboard into PS2/B You set up the pins with the following lines of code: PS2 mouse(5, 4); //PS2/A Mouse Clock = 5, Data = 4PS2 kbd(39, 41); //PS2/B Keyboard Clock = 39, Data = 41 Here's the simple test sketch #include <ps2.h>#define circuit Computing_Shieldunsigned int x_abs = 32767;unsigned int y_abs = 32767;int delta_x = 0;int delta_y = 0;/* * an arduino sketch to interface with a ps/2 mouse. * Also uses serial protocol to talk back to the host * and report what it finds. *//* * Pin 5 is the mouse data pin, pin 6 is the clock pin * Feel free to use whatever pins are convenient. */PS2 mouse(5, 4);PS2 kbd(39, 41);void kbd_init(){ char ack; kbd.write(0xff); // send reset code ack = kbd.read(); // byte, kbd does self test ack = kbd.read(); // another ack when self test is done}/* * initialize the mouse. Reset it, and place it into remote * mode, so we can get the encoder data on demand. */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(115200); mouse_init(); kbd_init(); Serial.println("Starting"); }/* * get a reading from the mouse and report it back to the * host via the serial line. */void loop(){ char mstat; char mx; char my; unsigned char code; /* get a reading from the mouse */ mouse.write(0xeb); // give me data! mouse.read(); // ignore ack mstat = mouse.read(); // left button = 001, right = 010 mx = mouse.read(); my = mouse.read(); if(mx>=0 && mx <= 127) { delta_x = mx; } if(mx>=128 && mx <= 255) { delta_x = -(255 - mx); } if(my>=0 && my <= 127) { delta_y = my; } if(my>=128 && my <= 255) { delta_y = -(255 - my); } x_abs = x_abs +delta_x; y_abs = y_abs +delta_y; Serial.print(mstat, BIN); Serial.print(" "); Serial.print("\tX="); Serial.print(mx, DEC); Serial.print("\tY="); Serial.print(my, DEC); Serial.print("\dX="); Serial.print(delta_x, DEC); Serial.print("\dY="); Serial.print(delta_y, DEC); Serial.print(x_abs, DEC); Serial.print(" "); Serial.print(y_abs, DEC); Serial.println();// code = kbd.read(); // Serial.print(code, HEX); // Serial.print(" ");} My more complicated sketch can be found on github gists here https://gist.github.com/anonymous/892a097bc8bbbbf1c5ca regards Ken