- Discrete LEDs
- Dot/Bar LEDs
- Matrix LEDs
- 7-Seg LEDs
- Serial -- Software
- Serial -- Hardware
- RS-232 via the MAX3232
- I2C -- EEPROM
- I2C -- DS1307 Real Time Clock
- 1-Wire -- DS18B20, Powered, Single-Drop
- 1-Wire -- DS18B20, Powered, Multi-Drop
- 1-Wire -- DS18B20, Parasitic, Multi-Drop
- TI Link Protocol -- Calculator Demo
- Infrared Communication
- MIDI -- Output Demo
- MIDI -- Input Demo
- MIDI to Analog Synth
Homemade Pressure Sensor
Here's an unusual device, and it takes me right back down Memory Lane. In 1982 I had a flash of inspiration: if one sandwiches a piece of conductive foam between two copper-clad boards, it makes an inexpensive pressure sensor. (Conductive foam is that black stuff, about a quarter inch thick used to pack and ship CMOS devices). When uncompressed, the resistance of the device is fairly stiff, but squish it together and the resistance drops substantially. So, you've got a variable resistor dependent on the pressure applied to it.
Well, I wrote it up for McGraw-Hill Electronics, which was the premier trade journal in those days, and lo, they published it. Even gave me an honorarium! The bibliographic details are "Conductive foam forms reliable pressure sensor," Electronics, May 19, 1982, pp. 161 and 163. If you'd like to read it, here's a scan:
The original application I had in mind was controlling electronic music synthesizers with the sensor. The circuit in that article from 35 years ago puts out an analog voltage, gate and trigger suitable for manipulating analog synths.
Then the flurry of activity set in! Not long after my article appeared, the well-known Forrest M. Mims latched onto it in his monthly column: "Making Your Own Pressure-Sensor Resistors," Computers & Electronics, November 1982, p. 124. This is the magazine previously known as Popular Electronics. He did credit me, however.
And then...one day, the phone rang. On the other end was some electronics designer from a mega toy company in California; you'd know the name, especially if you're the parent of a grade school aged daughter fond of dolls. He sort of beat around the bush for several moments, eventually quizzing me about the sensor, and I could tell what was coming. Eventually he sounded me out on whether I had filed for a patent. I said no. (Patents are a waste of time and have nothing to do with the inventor and everything to do with attorneys.)
A year later, this company put out a wonderful little musical toy: a four-banger electronic drum set with...wait for it...pressure sensitive pads.
Actually, that company gave me a pretty good idea in return and prompted me to show others how to fabricate their own pro quality percussion set for cheap. A couple years later I wrote "Build an Electric Drum Pad," Polyphony, December 1984, pp. 20-23. You can read this one, too. It appears on pp. 140-143 of my popular reprint book. The following link will take you to the PDF of the entire book.
And that brings us up to date. In this exercise you'll learn how make a pressure sensor and interface it to a PIC, using the PMP cross-compiler. Here's the schematic, which also shows the construction of the sensor:
A couple notes: the device is easy to make cheaply from scrap materials. Just don't expect it to act linearly or measure weights accurately. It really does register a fairly broad range, but probably logarithmically, just as a wild guess. Despite that, it should still find all sorts of use like synthesizer pitch bending, volume sensing drum pads (of course), sentry detection (put one under your "Welcome" mat), and more.
When making up the device, you'll want to test out several pieces of the foam. I've found the older stuff from 20 years ago works best. It's more solid and rubbery and has a wider variation of resistance under pressure. The newer stuff is almost too efficient and has a very low resistance uncompressed. The piece I ended up with after several attempts goes from 6k (squished) on up to 100k (uncompressed).
Once you have a satisfactory range, wrap the entire shebang with electrical tape.
The source code tries to take some of this variation into account. In particular, the Pascal constant SCALE, as the name implies, scales the full range of the sensor to something useful. Also, at power-up, the program self-calibrates the low end by detecting the steady-state uncompressed voltage, and this offset is subtracted once the program is running.
And, of course, you can adjust the value of R2 up or down, which is part of the voltage divider.
But in the final analysis, very little differs between this exercise and the previous two: the PIC senses a voltage by means of its ADC module and acts upon it.
Click to get the source code.
Click to get the schematic PDF.
Next Project: Sound Sensor -- Analog