Jeff Pearson
Member
I would have been totally lost without the Arduino IDE software. I do have a question. Here is a page from the ADNS2051 data sheet and my sketch so far. ADNS2051.h is in the Optimouse library. How do I send the configuration to the ADNS2051. Specifically, I want to make sure the RES is set to 800 counts per inch, and would like to set Sleep to Always awake. What is the line of code to put in the sketch. Thank you in advance
// ADNS2051.h reads out ADNS-2051 the Optical Navigation Sensor
// It's used in many cheap optical mice
//
// Written by Martijn The -> post [at] martijnthe.nl
// Tutorial: http://www.martijnthe.nl/optimouse/
// Based on the sketches by Beno”t Rousseau
// Trackball part of Panther XL clone
#include "ADNS2051.h"
#include <Bounce.h> // Create Bounce objects for each button. The Bounce object
// automatically deals with contact chatter or "bounce", and
// it makes detecting changes very simple.
#define SCLK 0 // Serial clock pin on the Arduino
#define SDIO 1 // Serial data (I/O) pin on the Arduino
ADNS2051 Optical1 = ADNS2051(SCLK, SDIO); // Create an instance of the ADNS2051 object
Bounce button2 = Bounce(2, 10); // if a button is too "sensitive"
Bounce button3 = Bounce(3, 10); // to rapid touch, you can
Bounce button4 = Bounce(4, 10); // increase this time.
void setup()
{
Serial.begin(38400);
Optical1.begin(); // Resync (not really necessary?)
pinMode(2, INPUT_PULLUP); // Left Mouse Click
pinMode(3, INPUT_PULLUP); // Middle Mouse Click
pinMode(4, INPUT_PULLUP); // Right Mouse Click
}
void loop()
{
button2.update();
button3.update();
button4.update();
if (button2.fallingEdge()) {
Mouse.press(MOUSE_LEFT);
}
if (button2.risingEdge()) {
Mouse.release(MOUSE_LEFT);
}
if (button3.fallingEdge()) {
Mouse.press(MOUSE_MIDDLE);
}
if (button3.risingEdge()) {
Mouse.release(MOUSE_MIDDLE);
}
if (button4.fallingEdge()) {
Mouse.press(MOUSE_RIGHT);
}
if (button4.risingEdge()) {
Mouse.release(MOUSE_RIGHT);
}
// 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,
{
Mouse.move(-1*Optical1.dx(), -1*Optical1.dy());
}
}
// ADNS2051.h reads out ADNS-2051 the Optical Navigation Sensor
// It's used in many cheap optical mice
//
// Written by Martijn The -> post [at] martijnthe.nl
// Tutorial: http://www.martijnthe.nl/optimouse/
// Based on the sketches by Beno”t Rousseau
// Trackball part of Panther XL clone
#include "ADNS2051.h"
#include <Bounce.h> // Create Bounce objects for each button. The Bounce object
// automatically deals with contact chatter or "bounce", and
// it makes detecting changes very simple.
#define SCLK 0 // Serial clock pin on the Arduino
#define SDIO 1 // Serial data (I/O) pin on the Arduino
ADNS2051 Optical1 = ADNS2051(SCLK, SDIO); // Create an instance of the ADNS2051 object
Bounce button2 = Bounce(2, 10); // if a button is too "sensitive"
Bounce button3 = Bounce(3, 10); // to rapid touch, you can
Bounce button4 = Bounce(4, 10); // increase this time.
void setup()
{
Serial.begin(38400);
Optical1.begin(); // Resync (not really necessary?)
pinMode(2, INPUT_PULLUP); // Left Mouse Click
pinMode(3, INPUT_PULLUP); // Middle Mouse Click
pinMode(4, INPUT_PULLUP); // Right Mouse Click
}
void loop()
{
button2.update();
button3.update();
button4.update();
if (button2.fallingEdge()) {
Mouse.press(MOUSE_LEFT);
}
if (button2.risingEdge()) {
Mouse.release(MOUSE_LEFT);
}
if (button3.fallingEdge()) {
Mouse.press(MOUSE_MIDDLE);
}
if (button3.risingEdge()) {
Mouse.release(MOUSE_MIDDLE);
}
if (button4.fallingEdge()) {
Mouse.press(MOUSE_RIGHT);
}
if (button4.risingEdge()) {
Mouse.release(MOUSE_RIGHT);
}
// 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,
{
Mouse.move(-1*Optical1.dx(), -1*Optical1.dy());
}
}