Advertisement
Guest User

Untitled

a guest
May 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. int updateCoord() {
  2. int axRaw, ayRaw, azRaw; // raw accelerometer values
  3. float ax, ay, az;
  4. int side = 0;
  5.  
  6. CurieIMU.readAccelerometer(axRaw, ayRaw, azRaw);
  7.  
  8. ax = convertRawAcceleration(axRaw);
  9. ay = convertRawAcceleration(ayRaw);
  10. az = convertRawAcceleration(azRaw);
  11.  
  12. if(ax > 0.8)
  13. side = 1;
  14. else if(ax < -0.8)
  15. side = 2;
  16.  
  17. if(ay > 0.8)
  18. side = 3;
  19. else if(ay < -0.8)
  20. side = 4;
  21.  
  22. if(az > 0.8)
  23. side = 5;
  24. else if(az < -0.8)
  25. side = 6;
  26.  
  27. /*if(oldSide!= side)
  28. {
  29. //CoordChar.setValue(side);
  30. if(side != 0){
  31. Serial.print("\n");
  32. Serial.print(side);
  33. }
  34. }*/
  35. //oldSide = side;
  36. return side;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement