-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learning Javascript Robotics
By :

Piezo elements can be really fun—you can use them to simply add music to your Johnny-Five projects. We're going to build a small project and play with some of the Johnny-Five utilities to make music with this fun little component.
Wiring a Piezo is pretty straightforward—you need to determine the + and - sides first. Usually, the + side is marked on the top of the plastic casing of the Piezo, and one leg is longer—much like an LED, the longer leg denotes the + side. Finally, some Piezo buzzers come with lead wires that are red (the + side) and black (the - side).
Once you've determined the + side, wire it to pin 3, and wire the - side to GND, as shown in the following diagram:
A Piezo wiring diagram
The script is a little more complicated than our last few scripts; we need to create a Piezo element, which just requires a pin. However, a piece of music is more complicated than turning...
Change the font size
Change margin width
Change background colour