While regular microphones pick up vibrations in the air, contact mics pick up vibrations in pretty much everything else. Clamp one to a tree branch, and you can hear rustling from the wind. Stick one to a thin sheet of metal, bang it, and you'll get some fun alien noises. You can even attach it to an acoustic guitar or other acoustic instrument and get a relatively clean recording of what it sounds like in real life.
Contact mics are just piezoelectric elements hooked up to an audio cord of some type, like an aux cable. In summary you just need to cut 1 end off of an aux cable, strip the wires in the cable, solder ground and a signal wire to the piezo element, then repeat if you want stereo
Okay cool lets dive in and make our own DIY Contact Mics.
Strip your audio cable and determine which wire is ground.
For TRS (Tip Ring Sleeve - like aux cables and 1/4" guitar cables) cables, ground is connected to the Sleeve part (furthest section from the tip).
Tip: Use a multimeter to check the resistance between a stripped wire and the sleeve section of the jack. The wire that reads something very close to 0 ohms resistance is your ground.
Here is an aux to RCA cable stripped.
Here is a 1/4" TRS Guitar cable stripped.
Solder the ground and L/R cables to your piezo elements. The outer ring of the element is ground. Mine had little wires pre-soldered.
Plug it in and make sure you are getting a signal.
And now you're done! Problem is, these things are very delicate. So you'll want to protect them in some way. At the very least, wrap some electrical tape around each of them. Or maybe glue them into a bottle cap or dip them in resin.
I opted for a 3D printed case since I have a 3D printer. I designed cases for a few standard sizes of piezo elements and magnets (these are fun to stick to metal so I recommend embedding magnets if possible). You can download them here.
Super glue the piezo elements and magnets into place. Route the wire into the channel and glue it.
Pay attention to magnet polarity if you are making a stereo pair - it's convenient for storage if they can snap together.
Now super glue the lid on and YA DONE.