- Wire
Gyro Sensor
I decided to put the MPU-6050 sensor and Arduino Nano instead of the Genuino 101 in the Cubecone.
(This project does not require a Bluetooth sensor.)
The RGB LED color changes according to the gyro value.
When you look at the video, you can see that the color changes normally.
If you move the gyro sensor, you can check that the gyro value changes through the serial monitor.
Code Explanation- Measure Gyro Values
const int MPU_addr=0x68;
Set the MPU_addr as the primary value of the gyro sensor.
Wire.begin();
Library initialization.
Wire.beginTransmission(MPU_addr);
Start communications with MPU_addr(0x68)
Wire.write(0x6B);
Reset
Wire.write(0);
When it receives a transmitting signal, it sends the value continuously.
Wire.endTransmission(true);
Transmit
Wire.beginTransmission(MPU_addr);
Communication start
Wire.write(0x3B);
Start transmission from 0x3B value.
Wire.endTransmission(false);
Continue without interrupting communication.
Wire.requestFrom(MPU_addr, 14, true);
Receive 14 register values.
GyX = Wire.read() << 8|Wire.read();
Push the first register value (0x3B) to the left by 8 spaces, put the second register value in that spaces.
Reference site
Comments
Please log in or sign up to comment.