模板:DelveBit arduino
来自Labplus盛思维基百科
#include <Wire.h>
int reading = 0;
void GetSensorValue(char address)
{
Wire.requestFrom(address, 2);
if (2 <= Wire.available())
{
reading = Wire.read(); // receive high byte (overwrites previous reading)
reading = reading << 8; // shift high byte to be high 8 bits
reading |= Wire.read(); // receive low byte as lower 8 bits
Serial.println(reading); // print the reading
}
}
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
}
void loop()
{
GetSensorValue(0x63);
}