WTF.
Senso:Could you direct me to the right bit-bang method?
I tried to implement Software I2C for Hmc6352 Compass
http://www.arduino.cc/playground/Learning/Hmc6352.
I have looked at:
-------------------------------------------
SoftI2CMaster: -------------------------------------------
.CPP:
http://blinkm-projects.googlecode.com/svn/trunk/blinkm_examples/arduino/BlinkMSoftI2CDemo/SoftI2CMaster.cpp.H:
http://blinkm-projects.googlecode.com/svn/trunk/blinkm_examples/arduino/BlinkMSoftI2CDemo/SoftI2CMaster.hI did not use this because there is no Software RECIEVE method.
-------------------------------------------
SoftTWI:-------------------------------------------
.CPP:
http://code.google.com/p/fivevolt/source/browse/Quadcopter/Arduino/Telemetry/SoftTWI.cpp.H:
http://code.google.com/p/fivevolt/source/browse/Quadcopter/Arduino/Telemetry/SoftTWI.hCode compiles but I always get 0.00 degrees. I used A5 and A4 because using Wire.H through the same code (replace every "compass." with "Wire."), I am able to get compass data. However, when I switch to SoftTWI I get 0.00.
#include "SoftTWI.h"
SoftTWI compass;
void setup()
{
Serial.begin(9600); // Initiate Serial
compass.attach(A5, A4);
compass.begin();
}
void loop(){
compass.beginTransmission(0x21);
compass.send(65); // Send "Get Data" command, info from Datasheet
delay(100); // interface command delay, info from Datasheet
compass.requestFrom(0x21, 2); //get the two data bytes, MSB and LSB
byte MSB = compass.receive(); // Result will be in tenths of degrees (0 to 3599)
byte LSB = compass.receive(); // Provided in binary format over two bytes."
compass.endTransmission();
// Compute result from the two bytes results
float myres = ((MSB << 8) + LSB) / 10;
// Display result
Serial.print(myres);
Serial.println(" degrees");
delay(1000);
}
Any thoughts?