This low cost module using four roller switches and a 3d printed bracket can be used to provide tilt information for a robot.
The idea is to use four roller ball tilt switches (about $.50 each from Amazon) and a 3d printed bracket to detect tilt. I designed a four degree tilt to each of the four "arms" so that the balls would roll downhill when the robot is level. By assigning the numbers "1" for north, "2" for east, "4" for south, and "7" for west it is possible to read each switch then add the numbers and know whether there is tilt and in what direction.
The leds shown below are just for testing--not part of the finished sensor.
I start with the tilt switch holder and insert the tilt switches. The "not active" end is pointed toward the center (longer wire, silver instead of brass). The "active" end--when lower than the other end--will result in continuity between the end wires.
I use wire wrap wire (then solder it) to connect the pins. The center position I tie to ground on the Arduino. Direction one goes to A0, direction two goes to A1, direction four goes to A2 and direction seven goes to A3 (since I used 12 Arduino Uno pins for servo control, I'm running low on input/output pins).
The final assembly, fastened to the dog using a wood screw, looks like this.