If you spend lots of time by computer, you notice how hard is to sit straight. Over time you lean down, slide under the table or find other position that seems to be comfortable. Well there are two theories of this thing – first of all naturally your body tries to find best position to prevent you from pains and fatigue. Anyway prolonged leaning may result in back or neck pain. So siting straight may prevent from those problems. Bu how to control yourself when you are focused in to your task. You can always feel how you are sitting. Coretech Robotics suggest simple project that may help to sit upright by reminding you all the time.
Device consists of ultarsonic sensor HC-SR04 which measures distance from your head. It is fixed to the backrest of chair at the head level. Attiny85 microcontroller monitors distance to the head and if distance increases meaning that you leaned, piezo speaker gives a signal so you could fix your position. Such solution may help you to develop a habit to sit straight as it will remind you all the time. But in other hand it also may become annoying as you can lean on purpose depending on your task you are doing. Since this is not complex and may be improved upon your needs.