Arduino Uno Gyroscope Control Code

MPU6050s are configurable accelerometers and gyroscopes. So you are capable to measure acceleration, rotation speed and temperature. The gravity is added to the acceleration. From these data the current angle of MPU6050 is calculated in degrees. You can set sensor ranges too. Bigger ranges imply less quility in measurements while smaller ranges makes the quility better. You can store a high variety of measured data to instantly react or later analyze them.

arduino uno with mpu
Figure 1 - Arduino Uno with MPU

Required hardware

  • Arduino Uno
  • MPU6050

Source code to install on controller


Before you upload this code to your Arduino, please format the EEPROM...
#include <OzIDManager.h>
#include <OzGyroscopeSensor.h>

OzIDManager* manager;
OzGyroscopeSensor* mpu6050;

void setup()
{
  Serial.begin(115200);

  manager = new OzIDManager;
  manager->_sendACK = true;
  manager->_checksum = true;

  OzCommunication::setIDManager(manager);

  mpu6050 = new OzGyroscopeSensor(); 

  int x=1;
  manager->sendLinkSetup();
  manager->PrintWelcomeLine(mpu6050, x++, "MyGyroscope");
}

void loop()
{
	OzCommunication::communicate();
	mpu6050->ownLoop();
}

More information