Piezo

A piezo flexes backwards and forwards as current is passed through it. By applying a voltage which alternates between on and off the piezo can be made to generate audible beeps and musical notes.

The piezo has a high resistance and requires low current to operate so can be controlled directly by a PICAXE output line.

Piezo transducers can either be PCB mounted or have 'flying leads' for panel or case mounting away from the circuit board.

Related Commands:

Print Page

Share

Schematic

PCB

Play tunes

This program will play pre-programmed tunes through a piezo sounder connected to output pin B.1, then play a user defined tune composed with the PICAXE ringtone Wizard.

Code Example:
main:	play B.1, 0	; Happy Birthday
	play B.1, 1 	; Jingle Bells
	play B.1, 2 	; Silent Night
	play B.1, 3	; Rudolph the Red Nosed Reindeer

	tune B.1, 5, ($00,$04,$06,$49,$07,$04,$00,$69,$66,$66,$66,$E7,$6C,$66,$66,$66,$67,$2A,$2B)

	pause 3000	; A short pause
	goto main	; Then repeat
Copy Code Submit an Example

Play sounds

This program will play an ascending sequence of tones through a piezo sounder connected to output pin B.1.

Code Example:
main:	for b1 = 1 to 100	; cycle through sounds
	  sound B.1, (b1,25)	; play that sound
	next b1
	pause 5000		; wait five seconds
	goto main		; repeat			; repeat
Copy Code Submit an Example

Play a 'happy sound'

This program will play 'a happy sound', an ascending sequence of tones, through a piezo sounder connected to output pin B.1.

Code Example:
main:	sound B.1,(50,10, 60,10, 100,50)	; play the sound
	pause 1000				; wait a second
	goto main				; repeat
Copy Code Submit an Example

Play a 'sad sound'

This program will play 'a sad sound', an descending sequence of tones, through a piezo sounder connected to output pin B.1.

Code Example:
main:	sound B.1,(60,10, 50,10, 40,50)		; play the sound
	pause 1000				; wait a second
	goto main				; repeat
Copy Code Submit an Example

Create Module

The piezo create module is used for generated beeps (sound command) and also playing ring tone music via the tune command.

Bill of Materials

DescriptionCodeQty
Miniature PCB piezo transducer SPE001 1 Buy Now
Miniature piezo transducer (flying lead) SPE002 1 Buy Now

Simulation

No Image Selected

Submit Your Own Code!

You must be logged in to submit code examples. Login now.