I began by constructing the water chambers from PVC pipe. It is very easy to work with and relatively inexpensive. I found that I needed to buy an automotive tap and die set, so I could add smaller fittings for the hose connections and sensors.
There are two chambers; one is for cold water where you place your hand and the other is for hot water. The premise here is that you place your hand into the cold water far enough for the water level rise to trigger a float switch and begin data logging. While there are several different options for data collection beyond that point, the initial plan is for you to press a button as you experience different levels of pain. When you can't handle the pain anymore, a hardware interrupt associated with the switch will reverse the flow of water (using solenoid valves) and flood the cold water chamber with hot water. It really feels quite pleasant! This is intended to simulate the effect of a pleasure or euphoric kind of pain reliever.
You may vary the time between the subject's pressing the pain relief button and the system's actual deliver of relief to study how perceived or actual delays in pain relief might contribute to the subject's subsequent self medication. There are many other ways to vary the program in order to advance our knowledge of pain using the pain machine. Incidentally, I think we need a much cooler name than "Pain Machine". Any ideas are welcome in the comments!