2469 views|0 replies

16

Posts

0

Resources
The OP
 

[Serial] [Starlight Lightning STM32F407 Development Board] Chapter 5 Buzzer Experiment [Copy link]

This post was last edited by hejecu on 2018-11-4 09:45 ChapterFiveChapter Buzzer Experiment 5.1 Purpose of the experiment The purpose of this experiment is to learn how to control the buzzer to make a buzzing sound through the IO port of STM32 and master the conventional control circuit of the buzzer. 5.2 Introduction to the experiment The buzzer is an electronic sound device with an integrated structure. It is powered by DC voltage and is widely used as a sound-generating device in electronic products such as computers, printers, copiers, alarms, electronic toys, automotive electronic equipment, telephones, timers, etc., as shown in the figure below.
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps1A05.tmp.png
Figure5.2.1
Buzzers can be divided into passive buzzers and active buzzers. In simple terms, active buzzers will sound when DC is applied, while passive buzzers will sound when a square wave with a frequency of 2K--5K is used to drive them. Otherwise, they will not sound when DC is applied directly.
In this experiment, the IO port outputs a high level, the transistor Q1 is turned on, the collector is at a low level, and the buzzer sounds. 5.3 Circuit Design The buzzer control pin is connected to the PC13 pin of STM32, as shown in Figure 5.3.1, where R18 is a current limiting resistor and R19 is a pull-down resistor. When the control pin outputs a high level, the transistor is turned on and the buzzer sounds; when the output is a low level, the transistor is turned off and the buzzer stops sounding. When configuring the pin, PC13 can be configured as a push-pull output.
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps1A15.tmp.png file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps1A16.tmp.jpg
Figure 5.3.1
5.4 Software Design
Open 3, program source code->1, basic experiment->experiment2buzzer experiment project in the CD directory, open the Beep.cfile under the BSP directory tree on the left, which is the driver file of the buzzer. The project directory is shown in the figure below,
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps1A27.tmp.jpg
Figure 5.4.1
OpenBeep.c file, the code is as follows:
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps1A28.tmp.jpg
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps1A29.tmp.jpg
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps1A3A.tmp.jpg
Figure5.4.2
Openmain.c file, initialize the system clock and buzzer output pin configuration, and finally turn on or off the buzzer every1S in thewhileloop. The code is as follows
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps1A3B.tmp.jpg
Figure5.4.3
5.5 Download Verification
Use a MINI USB cable to connect the computer and the development board through the USB port of CN3, turn on the power switch to power on the development board, the D3 power indicator lights up, connect the JLINK/ST-LINK download debugger, and open "Experiment 2 "Buzzer Experiment"Project code, compile and download, the buzzer will sound for 1 second and stop for 1 second, and so on.
This content is created by EEWORLD forum user hejecu. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

实验2 蜂鸣器实验.zip

641.48 KB, downloads: 8

This post is from stm32/stm8
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list