Hi,
I have a problem with accessing ADNS 2050E
I have a sourcecode but all I get from the arduino is 255-255. What do I do wrong? Is it the USB-UART interfering with the signals?
If someone knows what I have done wrong in the code please help me...
I have a ADNS 5020E that I try to read DeltaX and DeltaY from. But all I get is 255-255 from those registers. What do I do wrong. I have included a modified version of Benoît Rousseau's example. Please if soneone knows why I wont get this working please tell me... The code compiles allright. I have connected +5V and GND as well as SCK and SDIO to the Arduino.
#define CLOCK_PIN 2 //BROCHE_HORLOGE
#define PIN_DATA 3 //BROCHE_DONNEES
#define _BV(bit) (1 << (bit))
byte ReadRegister (byte adress) //LectureRegistre
{
int i = 7;
byte returnRead = 0;
pinMode (PIN_DATA, OUTPUT);
for (; i>=0; i--)
{
digitalWrite (CLOCK_PIN, LOW);
digitalWrite (PIN_DATA, adress & (1 << i));
digitalWrite (CLOCK_PIN, HIGH);
}
pinMode (PIN_DATA, INPUT);
delayMicroseconds(150);
for (i=7; i>=0; i--)
{
digitalWrite (CLOCK_PIN, LOW);
digitalWrite (CLOCK_PIN, HIGH);
returnRead |= (digitalRead (PIN_DATA) << i);
}
delayMicroseconds(150);
return returnRead;
}
void setup()
{
pinMode (CLOCK_PIN, OUTPUT);
pinMode (PIN_DATA, INPUT);
Serial.begin(19200);
}
void loop ()
{
if (ReadRegister (0x02))
{
Serial.print ('>');
Serial.print (ReadRegister (0x03), DEC);
Serial.print ('-');
Serial.print (ReadRegister (0x04), DEC);
Serial.println ();
}
if (Serial.available())
{
Serial.read();
}
}