Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Forked from azhaganandhan/.c
Created January 19, 2018 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shankardevy/3c95e1c1c0e15c0fcb00b689b6b8cfe8 to your computer and use it in GitHub Desktop.
Save shankardevy/3c95e1c1c0e15c0fcb00b689b6b8cfe8 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