C Programming for MCU<2>

Publisher:素心悠远Latest update time:2016-01-13 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Note: The following programs have been debugged by me and are successful.

Purpose: buzzer sound

The procedure is as follows:

 #include
 sbit buzzer=P3^5;
void delay02s (void)   //延时蜂灵
{
  unsigned x,y,k;
for(x=10;x>0;x--)
for(y=10;y>0;y--)
for(k=248;k>0;k--);
}
void main(void)      //主程序
 {
  while(1)
  {
    buzzer=0XFF;
    delay02s();
    buzzer=0X00;
    delay02s();
   }
  }

Reference address:C Programming for MCU<2>

Previous article:C Programming for MCU<1>
Next article:C Programming for MCU<3>

Recommended ReadingLatest update time:2024-11-15 17:57

STC89C52 microcontroller uses two timers to control the frequency and output time interval of the buzzer
topic Two timers are used to control the buzzer sound at the same time. Timer 0 controls the frequency, and timer 1 controls the duration of the same frequency. The output is 1, 10, 50, 100, 200, 400, 800, etc. at intervals of 300ms. 1k (hz) square wave. Problems encountered When timer disorder occurs, the priority
[Microcontroller]
STC89C52 MCU buzzer experiment
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include    reg52.h #define    uchar unsigned char   //Define unsigned  char as uchar #define uint  unsigned int                                                             sbit FMQ=P
[Microcontroller]
51 MCU Programming Buzzer Sounds Happy Birthday
Attached is the circuit diagram: (The information is mostly quoted from the masters on the Internet) #include #define uint unsigned int #define uchar unsigned char sbit speaker=P1^0; //The learning board given by the school is a bit inferior, using two I/O ports to control the buzzer. However, most learning b
[Microcontroller]
51 MCU Programming Buzzer Sounds Happy Birthday
The serial port communication microcontroller controls the buzzer to sound according to the digital data sent by the host computer.
1. Program Function When the host computer sends 1 to the microcontroller, the buzzer sounds at a frequency of 400ms. When 2 is sent, it sounds at a frequency of 200ms. When 3 is sent, it sounds at a frequency of 100ms. When 4 is sent, the buzzer is turned off.   2. Program source code #include reg52.h   /
[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号