/* Name: Doorbell designed with timer
Description: When the button is pressed, the buzzer emits a doorbell sound.
*/
#include
#define uchar unsigned char
#define uint unsigned int
sbit Key=P1^7;
sbit DoorBell=P3^0;
if p=0;
//Main program
void main()
{
DoorBell=0;
TMOD=0x00; //T0 mode 0
TH0=(8192-700)/32; //700us timing
TL0=(8192-700)%32;
IE=0x82;
while(1)
{
if(Key==0) //Press the button to start the timer
{
TR0=1;
while(Key==0);
}
}
}[page]
//T0 interrupt controls the dot matrix screen display
void Timer0() interrupt 1
{
DoorBell=~DoorBell;
p++;
if(p<400) //If you need to prolong the sound, you can adjust 400 and 800
{
TH0=(8192-700)/32; //700us timing
TL0=(8192-700)%32;
}
else if(p<800)
{
TH0=(8192-1000)/32; //1ms timing
TL0=(8192-1000)%32;
}
else
{
TR0=0;
p=0;
}
}
Previous article:Microcontroller C language programming: playing scales
Next article:Microcontroller C language programming: key control 8X8LED dot matrix screen display graphics
Recommended ReadingLatest update time:2024-11-15 18:00
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Regarding the question of whether the GND level is stable
- AD19 installation package always reports errors
- Tektronix offers free trials for more than 100 advanced application functions!
- Research on A-type digital flaw detection system based on FPGA.pdf
- Phase loss detection of three-phase three-wire circuit
- EEWORLD University Hall----Principle and Operation of DC Bridge Fudan University
- Small base stations can also take the center stage in the 5G era
- What is the packaging of integrated circuits? What are the common types of packaging? What are their respective characteristics?
- Vivado prompts [Synth 8-91] ambiguous clock in event control Problem Cause
- Simulation and Testbench Design.zip