I would like to build a cube with a Pi Zero inside and have the Pie be able to detect and report which side of the cube is facing up ... conceptually similar to rolling a dice and knowing what number is facing up. Can anyone give me an idea of what sensors I would need to be able to detect which side is up? I've done some searching to try and come up with an approach to it, but am at the point where I don't even know the right verbiage to ask the right question. Any thoughts on how to accomplish this would be appreciated. Thanks!
You need to use 3 axes accelerometer to sense which side of your cube is facing up. Accelerometers sense the gravity g and the acceleration due to motion.
Eg. when you roll dice, one of the axis will face down towards earth, let us assume positive x-axis exactly facing downwards, so the sensor will sense g along its positive axis which will be +9.8m/s^2, now suppose number you assigned to the face which is facing down is #1 you know #6 face is facing up, if g is -9.8m/s^2, #6 face will be facing down and face with #1 will be facing up.
The sensors available in the market comes with various interfaces namely:
- Digital interface:
- Analog Interface:
I would suggest you go for either I2C or SPI interface. And also go through these two articles on accelerometer basics and buying guide:
For projects and tutorials regarding the same, you will find plenty on the internet.