Design of AT89S51 microcontroller driving speaker to realize alarm function

Publisher:幸福家园Latest update time:2023-09-01 Source: elecfansKeywords:AT89S51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Use P1.0 to output 1KHz and 500Hz audio signals to drive the speaker as an alarm signal. It is required that the 1KHz signal sounds for 100ms and the 500Hz signal sounds for 200ms, alternately. P1.7 is connected to a switch for control. When the switch is closed, the alarm signal sounds. , when the switch is disconnected, the alarm signal stops and the program is programmed.


2. Circuit schematic diagram

Design of AT89S51 microcontroller driving speaker to realize alarm function

The P1.0 port in the "MCU System" area is connected to the SPK IN port in the "Audio Amplification Module" area with a wire;

Connect an 8-ohm or 16-ohm speaker to the SPK OUT port in the "Audio Amplification Module" area;

Connect the P1.7/RD port in the "SCM System" area to the K1 port in the "Four-way Toggle Switch" area with a wire;


3. Program block diagram

Design of AT89S51 microcontroller driving speaker to realize alarm function

4. Reference source program

FLAG BIT 00H

ORG 00H

START: JB P1.7, START

JNB FLAG, NEXT

MOV R2, #200

DV: CPL P1.0

LCALL DELY500

LCALL DELY500

DJNZ R2,DV

CPL FLAG

NEXT: MOV R2, #200

DV1: CPL P1.0

LCALL DELY500

DJNZ R2,DV1

CPL FLAG

SJMP START

DELY500: MOV R7, #250

LOOP: NOP

DJNZ R7,LOOP

RET

END


Keywords:AT89S51 Reference address:Design of AT89S51 microcontroller driving speaker to realize alarm function

Previous article:Data type analysis in 51 microcontroller
Next article:Introduction to the functions of various system boards of AT89S51 microcontroller

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号