Piezo Disc

From ElectroDragon Wiki

蜂鸣片的原理

蜂鸣片是利用压电效应原理工作的,当对其施加交变电压时它会产生机械振动;
反之,对其施加机械作用力时它也会产生电压信号。
因此,可以将压电陶瓷蜂鸣片变通作为振动传感器使用。
压电陶瓷蜂鸣片受到机械作用力时产生的电压信号很微弱,作振动传感器使用一般应连接电压放大器。

The buzzer works based on the principle of piezoelectric effect. When an alternating voltage is applied to it, it will produce mechanical vibration;
Conversely, it generates a voltage signal when a mechanical force is applied to it.
Therefore, the piezoelectric ceramic buzzer can be used as a vibration sensor.
The voltage signal generated by the piezoelectric ceramic buzzer when it is mechanically applied is very weak. Generally, it should be connected to a voltage amplifier as a vibration sensor.

Use as input by vibration

Demo Code

void setup()
{
Serial.begin(9600); //Open the serial to set the baud rate for 9600bps
}
void loop()
{
int val;
val=analogRead(0); //Connect the analog piezoelectric ceramic vibration sensor to analog interface 0
Serial.print("Vibration is ");
Serial.println(val,DEC);//Print the analog value read via serial port
delay(100);
}

Use as a buzzer