Toilet paper

Toilet Paper
Harlan Hile and Drew Perttula

University of California, Berkeley

10/16/2000

Introduction
This whole project began simply as a remodeling project, to repaint and re-floor a water closet. As time went on, it was decided that there was no reason to stop there, and we sought to bring the room into the high-tech realm. Although documentation on using Python in such an environment was scarce, we believe it was the right choice for the project.

Since then, the water closet has finally advanced to the

and the computer running it have developed into a very unusual use of Python.

The main objective of this project is to have fun, and create a smart, interactive, mysterious, and amusing bathroom going experience. However, it can also be viewed at as an experiment in home automation, artificial intelligence, and user interfaces.
 

Technology Overview

An inexpensive IBM 486 computer called toilet has been "installed" in the water closet alongside the real toilet. Toilet runs Slackware Linux and contains a sound card with joystick port, an ethernet card, standard parallel and serial ports, and a CD-ROM drive. The case is on the floor with a special cover (this is an especially adverse environment), and a mini keyboard is mounted on the wall.

Most data is acquired through the joystick port of the sound card, which gives 4 analog values (the axes) and 4 digital on/off values (the buttons). A few input bits of the parallel port are also used to read digital on/off values. See the schematic for a complete list of inputs and outputs.


 
How Python Fits in
 
We chose Python for its incredible prototyping speed and ease of extensibility. The interfaces to the parallel port, joystick port, and CD-ROM are custom C modules, for example. Older versions of the toilet software called separate programs from a script and parsed their output. Under Python's module system, our scripts are shorter, clearer, and faster.

Toilet also makes use of various modules written by others. In order to get news headlines from the web, it has httplib fetch selected web pages and the re module parse the headlines out of them. Once it has these headlines, it scrolls them across the LCD screen using termiosmodule. The sound output system uses the linuxaudiodev and wave modules to play .wav sounds. Toilet also uses a DB-API module to store history into a database and socket to listen for requests from other processes.

 
Python's threading is also used to allow sequences of events to execute, while input data is still polled, and locks are used to synchronize threads.
What it Does

When a motion sensor detects a visitor in the hallway outside, toilet picks from a list of sounds to play to encourage a visitor to enter. When Toilet has a visitor, it picks an appropriate track to play from the CD based on things like the seat positions, the laser beam across the seat being broken, the light switch being off, etc. It scrolls news headlines across the LCD panel. When the toilet is flushed, the lights flash and the music fades. If the seat is left up when the door is opened, a reminder sound plays. Toilet also serves web pages to the outside that allow us to view history from the database, request specific CD tracks, control the volume, and send messages to the LCD screen.

Conclusion

Toilet has been in development for nearly two years. We have used Python for about 3 months, during which time the development has gone significantly faster.

With the available sensors, and easy control and manipulation through Python, Toilet can be expected to do many more intelligent and entertaining things.