Piezobuzzer - skyrockprojects/wearable-tech GitHub Wiki

Welcome to the Piezobuzzer wiki!

Table of contents


  1. Piezo
  2. Buzzer
  3. How to use a Piezobuzzer

1. Piezo

Piezoelectricity /piˌeɪzoʊˌilɛkˈtrɪsɪti/ is the electric charge that accumulates in certain solid materials (such as crystals, certain ceramics, and biological matter such as bone, DNA and various proteins) in response to applied mechanical stress. (wiki)

2. Buzzer

A buzzer or beeper is an audio signalling device, which may be mechanical, electromechanical, or piezoelectric (piezo for short). Typical uses of buzzers and beepers include alarm devices, timers, and confirmation of user input such as a mouse click or keystroke.(wiki)

3. How to use a Piezobuzzer

Piezobuzzer can use as input and output as well.
So, as input we normally use analogRead.
But, as output we use digitalWrite to make sound in different frequency.

analogRead(pin)
digitalWrite(pin)

source1
source2

3.1 Why analogRead?

DigitalRead only read 1 and 0, so you can see 1 and 0 ONLY. But analogRead read 0~1023, more range can use.

3.2 How to use digital pin?

Normally we can use digitalWrite as output control, but when we use buzzer,we use this one:

    tone(buzzer,659,300);

source

Syntax

tone(pin, frequency)
tone(pin, frequency, duration)