You have two different devices.
If you test them individually do they function correctly? Did you test them?
When you say two you mean: HMC6352 & ADNS2620? Yes I did, here is the working code for each:
ADNS2620 #include <adns2620.h>
ADNS2620 mouse(18,19);
void setup()
{
mouse.begin();
delay(100);
mouse.sync();
mouse.write(CONFIGURATION_REG, 0x01);
Serial.begin(9600);
}
void loop()
{
if (Serial.available() > 0)
{
int incomingByte = Serial.read();
if (incomingByte == 'a')
{
int8_t delta_X = mouse.read(DELTA_X_REG);
int8_t delta_Y = mouse.read(DELTA_Y_REG);
Serial.print(delta_X, DEC);
Serial.print(',');
Serial.println(delta_Y,DEC);
}
}
}
HMC6352 #include "Wire.h"
void setup()
{
Serial.begin(9600); // Initiate Serial
Wire.begin();
}
void loop(){
Wire.beginTransmission(0x21);
Wire.send(65); // Send "Get Data" command, info from Datasheet
delay(100); // interface command delay, info from Datasheet
Wire.requestFrom(0x21, 2); //get the two data bytes, MSB and LSB
byte MSB = Wire.receive(); // Result will be in tenths of degrees (0 to 3599)
byte LSB = Wire.receive(); // Provided in binary format over two bytes."
Wire.endTransmission();
// Compute result from the two bytes results
float myres = ((MSB << 8) + LSB) / 10;
// Display result
Serial.print(myres);
Serial.println(" degrees");
delay(1000);
}
They both function correctly when either one of them is connected to the arduino alone. But together it will not work!