For example, if the range is ☒g, the divisor is 16384.0. The divisor depends on what the range is set to and can be found in the MPU6050’s datasheet. In the loop() function, readAccel() is called with the divisor passed in as an argument.
Once the device is configured, the program waits 10 seconds to let the MPU6050 stabilize. The range can be set to ☒g, ±4g, ☘g, or ☑6g by setting the AFS_SEL bits (bits 3 and 4 of register 0x1C). Next, setAccelSensitivity() is called, with the range passed in as an argument. If the device is not reset on power up, it will stay in sleep mode. The function resetMPU() is called to reset all internal registers of the MPU6050 to their default states by writing 0x00 to register 0圆B.
#Mpu6050 proteus library download serial#
In the setup() function, we initialize I2C communication with Wire.begin() and the serial communication with Serial.begin() to display data on the Serial Monitor. Let’s start with one of the easy parts – obtaining the raw accelerometer data from registers 0x3B to 0x40. The MPU6050’s gyroscope has a user-programmable range of ☒50, ±500, ☑000, and ☒000°/sec (DPS). The axes relative to the module are shown in the image below. For example, if you have a wheel that spins once per second, it has an angular velocity of 360 degrees per second. The gyroscope measures angular velocity which has units in degrees per second. This perpendicular displacement causes a change in the capacitance between the microstructures which can be measured and processed. The MPU6050’s accelerometer has a user-programmable range of ☒g, ±4g, ☘g, and ☑6g.Ī gyroscope works on the principles of the Coriolis effect where an external force causes the mass moving in a rotating system to move perpendicular to both the direction of motion and the axis of rotation. Whichever technique an accelerometer uses, the gravitational acceleration along all three axes can be calculated, and the angle at which the sensor is positioned can be known. This capacitance is measured and processed to correspond to a certain acceleration. When a force is applied, the microstructures move and causes a change in capacitance. When the microstructures are static (no external force exerted on the sensor), there is a certain capacitance between them. The second technique uses two microstructures. When these structures experience a force, a voltage is generated based on the magnitude of the force. The first technique is called the piezoelectric effect, which works with microscopic crystal structures. Accelerometers can be manufactured based on different techniques.