Hi! I'm trying to use a Gy-521 and it's only giving me -1 in the serial monitor. I have no idea what I'm doing wrong and chatgpt wouldn't help me :/. Please help! This is my code:
#include<Wire.h>
int16_t GyX;
void setup() {
Wire.begin();
Wire.beginTransmission(0x68);
Wire.write(0x6b);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Wire.beginTransmission(0x68);
Wire.write(0x43);
Wire.endTransmission(false);
Wire.requestFrom(0x68,2,true);
GyX=Wire.read()<<8|Wire.read();
Serial.println(GyX);
delay(250);
}