Hallo,
danke schonmal für die schnellen Antworten!
Bin begeistert!
Zu Eisbear
"wnn Du sagst, daß Du die kooerdinaten über usb überträgst, meinst Du sicher, die daten vom uno auf den computer, oder? die daten vom maussensor kriegst Du nicht über usb in den arduino..."
Ja klar, das meinte ich, hab mich zu undeutlich ausgedrückt.
Ich "zapfe" die Pins des Sensors direkt an und die gehen aufs Arduino. Ich habe eine fertige Library dafür benutzt. Alleine hätte ich das nicht so schnell hinbekommen...
Hier mal das Programm:
//#include "PAN3101.h"
#include "ADNS2051.h"
// #include "ADNS2610.h"
// #include "ADNS2083.h"
#define SCLK 2 // Serial clock pin on the Arduino
#define SDIO 3 // Serial data (I/O) pin on the Arduino
//PAN3101 Optical1 = PAN3101(SCLK, SDIO); // Create an instance of the PAN3101 object
ADNS2051 Optical1 = ADNS2051(SCLK, SDIO);
// ADNS2610 Optical1 = ADNS2610(SCLK, SDIO);
// ADNS2083 Optical1 = ADNS2083(SCLK, SDIO);
signed long x = 0; // Variables for our 'cursor'
signed long y = 0; //
int c = 0; // Counter variable for coordinate reporting
void setup()
{
Serial.begin(38400);
Optical1.begin(); // Resync (not really necessary?)
}
void loop()
{
// The status commands are available only for the PAN3101 and the ADNS2051:
// Optical1.updateStatus(); // Get the latest motion status
// if (Optical1.motion()) // If the 'Motion' status bit is set,
// {
x += Optical1.dx(); // Read the dX register and in/decrease X with that value
y += Optical1.dy(); // Same thing for dY register.....
// }
if (c++ & 0x80)
{ // Report the coordinates once in a while...
Serial.print("x=");
Serial.print(x, DEC);
Serial.print(" y=");
Serial.print(y, DEC);
Serial.println();
c = 0; // Reset the report counter
}
}