Skip to content

Instantly share code, notes, and snippets.

@azhaganandhan
Created January 19, 2018 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save azhaganandhan/3e491bb6b5856bc510591c7e6a1910a1 to your computer and use it in GitHub Desktop.
Save azhaganandhan/3e491bb6b5856bc510591c7e6a1910a1 to your computer and use it in GitHub Desktop.
#include <Wire.h>
void setup() {
// put your setup code here, to run once:
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600);
}
int reading = 0;
void loop() {
Wire.beginTransmission(0);
Wire.write(0xaa);
Wire.write(0x00);
Wire.write(0x00);
Wire.endTransmission();
delay(20);
Wire.beginTransmission(0);
Wire.write(0x00);
Wire.endTransmission();
Wire.requestFrom(0, 7);
if (7 <= Wire.available()) {
reading = Wire.read();
reading = reading << 8;
reading |= Wire.read();
Serial.println(reading);
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment