Memsic Program
Newzed
Posts: 2,503
I had to repost this - error in the file heading.
I have modified the Sample code that comes with the Memsic so it displays a reading ONLY if X or Y has changed.· If the Stamp detects that the new X and Y readings are the same as the last displayed readings, then it skips the display.· Really removes a lot of clutter from the debug screen - now you get a reading only when X or Y changes.
Sid
I have modified the Sample code that comes with the Memsic so it displays a reading ONLY if X or Y has changed.· If the Stamp detects that the new X and Y readings are the same as the last displayed readings, then it skips the display.· Really removes a lot of clutter from the debug screen - now you get a reading only when X or Y changes.
Sid
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Sid
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Sid
· IF (xTilt <> oldX) OR (yTilt <> oldY) THEN
··· ' display new values
··· oldX = xTilt
··· oldY = yTilt
· ENDIF
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Just a reminder for use with Jon's otherwise fine routine. Make sure during initialization to do a "first_time_read" of the accelerometer, so that you can initialize the saved variables:
/code
first_time_read: 'Prime accelerometer values
GOSUB Read_Memsic 'Obtain present values for X and Y Tilts
oldX = xTilt 'Save xTilt
oldY = yTilt 'Save yTilt
either that, or guarantee a mis-match by doing this:
oldY= $FF
oldY= $FF
code/
If I had a nickel for everytime I forgot to inititalize a variable on start-up over the years, I'd be a very rich man!
Regards,
Bruce Bates