“A while ago I saw a hourglass project online that I thought would be nice to build, after the tribulations of sourcing some missing files and getting the project to compile I found I didn’t have the right accelerometer, the project required an ADXL343 and I had an ADXL345, so I decided to fork the code to that accelerometer.
I initially attempted to modify the code without making substantial changes but couldn’t get it to work so I set about looking for a solution.
I eventually located a datasheet containing a block of code designed to keep a picture on a smartphone upright while you rotated it in your hand and I built this project to test things out before modifying my hourglass project.
Initially it didn’t work as I missed the fact that the orientation code works in g force and the Adafruit sensor library gives its results in m/(s^2), after realising this I used an online calculator to do a conversion which fixed the problem.
The board is one I had built for a previous project, it connects up an Arduino nano to a MAXX7219 display and an ADXL345 accelerometer.
There are 11 wires on top and 20 breaks on the underside of the board.
Reflecting on the build I now think it would have been better to use a right angle connector for the accelerometer; as things are currently set up you have to twist the board back to front to move through the sensed points rather than rotating it. I also added in a 0.1 inch 5 way socket to mount the display to the board.
If you do not have any of these they can be downloaded via Sketch->Include Libraries->Manage Libraries…
I modified the Adafruit ADXL345 sensortest.ino sketch by adding in the orientation code from the datasheet and code to run the matrix display.”