51 MCU buzzer program

Publisher:RadiantEyesLatest update time:2020-03-16 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#include"reg52.h"

typedef unsigned char u8;

typedef unsigned int u16;

sbit beep=P1^5;

void delay(u16 i)

{

while(i--);

}

void main()

{

while(1)

{

beep=~beep;

delay(1000); //control tone frequency

beep=~beep;/control the volume of the sound

delay(10);

 }

}


Reference address:51 MCU buzzer program

Previous article:51 MCU [IV] Buzzer crystal oscillator MCU frequency
Next article:51 single chip microcomputer buzzer plays "My Motherland and I"

Recommended ReadingLatest update time:2024-11-16 13:27

STC89C52 single chip microcomputer buzzer singing experiment
////////////////////////////////////////////////////////////////////////   Function: By configuring the MCU timer to generate square waves of different frequencies, the buzzer           will make different sounds according to the different frequencies to achieve the purpose of singing.   Experimental board model: KB
[Microcontroller]
Multi-mode 51 single-chip heart-shaped water light + breathing light + buzzer music
1. Basic hardware DIY design Circuit Hardware: STC89C52RC Buzzer/24 LEDs/4 corner buttons 1) Overall schematic diagram 2) PCB circuit 3) 3D_PCB TOP layer 2. MCU Programming 1) Breathing light //Breathing light while(1) { for(high=1;high cycle;high++) { P2=P1=P0=0XFF; delay2(high); P2=P1=P0=0X00;
[Microcontroller]
Multi-mode 51 single-chip heart-shaped water light + breathing light + buzzer music
#51 MCU# Using interrupt to realize buzzer
Buzzers are often used as reminder sounds in computers, printers, multimeters and other equipment. The reminder sounds are usually very simple, as long as they sound. The schematic diagram of the buzzer of a certain microcontroller: The CPU schematic diagram of the microcontroller: The following program uses the
[Microcontroller]
#51 MCU# Using interrupt to realize buzzer
C51 single chip buzzer two butterfly code
#include // This is the code generated by the MCU music code generator #define uchar unsigned char sbit beepIO=P1^5; // Output is P1.5, can be changed to other IO ports flying m,n;  uchar code T ={{0,0}, {0xF8,0x8B},{0xF8,0xF2},{0xF9,0x5B},{0xF9,0xB7},{0xFA,0x14},{0xFA,0x66},{0xFA,0xB9},{0xFB,0x03},{0xFB,0x4A},{0xFB,0
[Microcontroller]
Microcontroller for beginners (22) IO port: How to use the buzzer/How the transistor works
====================================== This article continues the content of the previous article. Let’s do experiment 4: control the active buzzer with a button. The buzzer sounds when the button is pressed and stops when the button is released. buzzer Before experiment 4, let's briefly introduce the buzzer. Ther
[Microcontroller]
Microcontroller for beginners (22) IO port: How to use the buzzer/How the transistor works
Microcontroller tutorial 2: Buzzer singing
Using a single-chip microcomputer (or single-board computer) to play music is probably one of the issues that radio enthusiasts are interested in. This article starts from the basic   sound generation experiment of the single-chip microcomputer, discusses the design principle of the music program, and gives specific e
[Microcontroller]
Microcontroller tutorial 2: Buzzer singing
C51 Buzzer Happy Birthday Code
#include #define uint unsigned int  #define uchar unsigned char sbit beep = P1^5; uchar code SONG_TONE ={212,212,190,212,159,169,212,212,190,212,142,159, 212,212,106,126,159,169,190,119,119,126,159,142,159,0}; uchar code SONG_LONG ={9,3,12,12,12,24,9,3,12,12,12,24, 9,3,12,12,12,12,12,9,3,12,12,12,24,0}; //Delay void D
[Microcontroller]
Simple electronic keyboard program - using buzzer to make sound
/* Program effect: The digital tube displays the input, and the digital tube displays incrementally, just like entering a number when making a phone call. At the same time, the buzzer emits a different rhythm. The program is simple and compact. It is relatively difficult to understand, but as long
[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号