Friday, June 27, 2014

Real time 2D visualization on Matlab for GY-521 MPU-6050 IMU



Watch the demo video:








Circuit used





I used "GY-521 which has "MPU-6050" sensor which contains an accelerometer and a gyro on one chip. 


Connections:

VCC on GY-521 ---->  to 3.3v pin on Arduino
GND on GY-521 ---->  to GND  pin on Arduino
SCL  on GY-521 ---->  to PinA5 on Arduino
SDA on GY-521 ---->   to PinA4 on Arduino


Codes

I used 2 codes. The first one should be uploaded to the Arduino board. It is responsible for detecting one of the 3 angles of the sensor, and sending its value to the computer via USB. 

The other code is a Matlab code responsible for receiving the angle from the Arduino and visualizing it on a 2D object.


Arduino Code, Matlab code, and Libraries needed:

https://drive.google.com/folderview?id=0Bx4uoJmyE27YOHBqUzVsLU9XTVE&usp=sharing

Move "I2Cdev" & "MPU6050" folders to 

Documents > Arduino > libraries 




Real time plotting of distance on Matlab using Arduino Uno & PING)))



Watch the demo video:







Circuit used





I used "PING)))" ultrasonic sensor that has only 3 pins.



Connections:

GND  Pin on PING)))  ----> to GND pin on Arduino 
5V      Pin on PING)))  ----> to 5V pin on Arduino
SIG     Pin on PING)))  ----> to digital pin  7 on Arduino (You may use any other digital pin)


Codes

There are 2 codes. The first one should be uploaded to the Arduino board. It is responsible for detecting the distance of the closest object in front of the sensor, and sending the distance to the computer via USB. 

The other code is a Matlab code responsible for receiving the distance from the Arduino and plotting it.




Arduino & Matlab codes: