Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. %% setup
  2. hold all
  3. a=arduino;
  4. mpu=i2cdev(a,'0x68'); %mpu adress is normally 0x68
  5. writeRegister(mpu, hex2dec('B6'), hex2dec('00'), 'int16'); %reset
  6. data=zeros(10000,14,'int8'); %prelocating for the speed
  7. j=1;
  8. a1 = animatedline('Color',[1 0 0]);
  9. a2 = animatedline('Color',[0 1 0]);
  10. a3 = animatedline('Color',[0 0 1]);
  11. legend('Accel_x','Accel_y','Accel_z')
  12.  
  13. %% loop
  14. while(true)
  15. x=1;
  16. for i=59:72 % 14 Data Registers for Accel,Temp,Gyro
  17. data(j,x)= readRegister(mpu, i, 'int8');
  18. x=x+1;
  19. end
  20. y=swapbytes(typecast(data(j,:), 'int16')) %if your system is big-endian remove the swapbytes function
  21. addpoints(a1,j,double(y(1)));
  22. addpoints(a2,j,double(y(2)));
  23. addpoints(a3,j,double(y(3)));
  24. j=j+1;
  25. drawnow limitrate
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement