0

members

Easy Project 19g Raspberry PI Zero W board - Buzzer

of Acoptex.com in Raspberry Pi Zero W

Raspberry basics: Project 19g

Project name: Raspberry PI Zero W board - Buzzer

Tags: Raspberry, Raspberry PI Zero W board, vers 1.1, v 1.1, buzzer, RPi.GPIO library, time library

Attachments: buzzer.py

Raspberry Pi
Monitor or TV
HDMI cable
USB keyboard
USB mouse
Power supply
8GB SD card

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1. Raspberry PI Zero W board 1 pc

2. Micro SD card with NOOBS and SD card adapter 1 pc

3. Micro USB power supply (2 A 5V or 5V 3A) 1 pc

4. USB keyboard 1 pc

5. USB mouse 1 pc

6. TV or PC monitor 1 pc

7. HDMI cable 1 pc

8. T-Cobbler Breakout and GPIO Cable 1 pc

9. Micro USB 2.0 OTG Cable 1 pc

10. Mini HDMI to HDMI Adapter (HDMI to Mini HDMI Adapter) 1 pc

11. 4-Port USB 2.0 Hub 1 pc

12. Breadboard 1 pc

13. Active piezo buzzer 1 pc 

14. Jumper cables F-M, M-M

15. NPN transistor (8050) 1 pc

16. Resistor  1 pc (1 KOhm)

General

We will learn learn how to drive an active buzzer with a PNP transistor to make sounds with Raspberry PI Zero W board. 

Understanding the S8050 NPN Epitaxial Silicon Transistor

You can find datasheet here.

Understanding the buzzer

As a type of electronic buzzer with integrated structure, buzzers, which use DC power supply, are widely used in computers, printers, photocopiers, alarms, electronic toys, automotive electronic equipments, telephones, timers and other electronic products for voice devices. Buzzers can be categorized as piezoelectric and magnetic buzzers. A piezoelectric buzzer is mainly composed of multivibrator, piezoelectric buzzer slice, impedance matcher, resonance chamber, shell, etc. A magnetic buzzer is mainly composed of oscillator, electromagnetic coil, magnet, vibrating diaphragm, shell, etc. Buzzers can also be categorized as active and passive buzzers (See the following pictures). When we place the pins of two buzzers upwards, we can see the one with green circuit board is a passive buzzer, while the one without circuit board instead of enclosing with black tape is an active buzzer.

The difference between an active buzzer and a passive buzzer is:

The active buzzer has built-in oscillating source, so it will make sounds as long as it is electrified. While the passive buzzer does not have oscillating source, so it will not tweet if you use DC signals, instead you must use square waves whose frequencies are between 2K and 5K to drive it. The active buzzer is often more expensive than the passive because multiple built-in oscillating circuits exist.

In this project, we use an active buzzer. When we make the GPIO of Raspberry Pi output low level (0V) by programming, the transistor will conduct because of current saturation and the buzzer will make sounds. But when we supply high level to the IO of Raspberry Pi, the transistor will cut-off and the buzzer will not make sounds.

Understanding the Raspberry PI Zero W board

You can read more about it here.

Signals and connections of the Raspberry PI Zero W board


Wiring


Step by Step instruction

We recommend using a high-performance SD card for increased stability as well as plugging your device into an external display to see the default application booting up.

1. Setup and preparation

We assume that you have Windows 10 installed on your PC and Raspbian OS installed on your Raspberry Pi Zero W board. 

  1. Do wiring.
  2. Insert your micro SD card with Raspbian OS into the TF card slot on the Raspberry Pi Zero W board. It will only fit one way.
  3. Connect Raspberry PI Zero W board mini HDMI port to your TV or Monitor HDMI (DVI) port (use HDMI cable and mini HDMI to HDMI adapter and/or HDMI to DVI adapter).
  4. Make sure that your monitor or TV is turned on, and that you have selected the right input (e.g. HDMI/DVI,  etc).
  5. Plug in micro USB 2.0 OTG Cable to USB data port of Pi Zero and 4-Port USB 2.0 Hub to micro USB 2.0 OTG Cable. 
  6. Plug in your USB mouse and USB keyboard to 4-Port USB 2.0 Hub.
  7. If you intend to connect your Raspberry Pi Zero vers 1.2 or vers 1.3 to the internet, connect a WiFi dongle to one of the 4-Port USB 2.0 Hub ports.
  8. Connect Micro USB power supply to Raspberry PI Zero board micro USB input.
  9. The Raspberry PI desktop will start up.
  10. Open Terminal window and type the command: sudo apt-get update
  11. Then type the command: sudo apt-get install 

2. Making the program

  1. Type this command in the Terminal: sudo nano buzzer.py

  2. Copy and paste the code from buzzer.py to opened window. Since it is a Python code, you need to be careful with the Tab characters as it is important to group the instruction as blocks in Python.

  3. Press Ctrl+X, Y, Enter buttons to save the file.
  4. Type the command in the Terminal: sudo python buzzer.py

  5. It will make a sound as programmed.

Code

The code is well explaned. Please check the comments in the code.

Summary

We have learnt how to drive an active buzzer with a PNP transistor to make sounds with Raspberry PI Zero W board.

Libraries in use

  • RPi.GPIO
  • time

Script

  • Look for attached code on the begining of this project


Other projects of Acoptex.com
Medium Basics: Project 083w Sipeed Maixduino board - Using PlatformIO IDE of Acoptex.com in Sipeed Maixduino 08-08-2019

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 27-12-2018
Viewed: 369 times