I've had a standing desk at work for a long time, but I've always felt that I wasn't using it enough, that I still spent most of my timing sitting.
This week I finally decided to do something about it.
I bought a small sonar sensor (LV-MaxSonar-EZ1), hooked it up to an Arduino and added a little Python script to sample the sensor once a minute.
The sonar is mounted to my table and measures the distance to the floor, and with ~3 cm accuracy it's very easy to distinguish whether I'm sitting or standing.
Since the Sonar happily runs of 5V, I just connected its power input pins directly to the VCC and GND pins of my Arduino. Conveniently it also provides the measured distance as analog voltage on a pin, I just connected that to A0 on the Arduino.
The Arduino code to regularly sample the sonar is …