I have a piezoelectric sensor. Both pins are the same length. I have one like this: Piezo picture. On the Piezo it's written muRata and 01P. How do I know which do I send to the digital pins and which to the ground? I have an Arduino Uno.
On the one I have, the shorter pin is ground. I discovered that empirically - a scientific word for "I tried it the wrong way round the first time but the magic smoke stayed inside." Afterwards I inspected it more carefully, I found a '+' embossed in the top surface nearer one side. :-o
If you're using just one or sound quality doesn't matter: it doesn't matter.
Otherwise you need to figure it out with a scope like this:
- Connect both poles of the connector of the PZT to an oscilloscope (time base approx. 50ms/div, y-axis 200mV/div).
- Slightly tap the head of the PZT with your finger. As a result you should get a voltage pulse on the oscilloscope.
- Positive Amplitude -> + pole of the piezo is connected to the inner conductor of the oscilloscope BNC connector.
- Negative Amplitude -> + pole of the piezo is connected to the outer conductor of the oscilloscope BNC connector.