-
-
Save azhaganandhan/3e491bb6b5856bc510591c7e6a1910a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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