Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. %% Sample each axis and return the average as an integer
  2.  
  3. function y = readAxis(ard, axisPin)
  4.  
  5. reading = int32(0);
  6. sampleSize = int32(10);
  7.  
  8. ard.analogRead(axisPin);
  9.  
  10. for i = 0:1:sampleSize
  11.  
  12. reading = reading + int32(ard.analogRead(axisPin));
  13.  
  14. end
  15.  
  16. y = reading/sampleSize;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement