当前位置:网站首页>Application of 51 single chip microcomputer timer
Application of 51 single chip microcomputer timer
2022-07-03 09:55:00 【Yiao】
control LED Blink for one second
#include"reg51.h"
typedef unsigned int u16;
typedef unsigned char u8;
sbit led1=P2^0;
sbit led3=P2^2;
sbit led5=P2^4;
sbit led7=P2^6;
void Timer0Init()
{
TMOD|=0X01;
TH0=0XFC;
TL0=0X18;
EA=1;
TR0=1;
ET0=1;
}
void main()
{
Timer0Init();
while(1);
}
void Timer0() interrupt 1
{
static u16 i;
TH0=0XFC;
TL0=0X18;
i++;
if(i==1000)
{
i=0;
led1=~led1;
led3=~led3;
led5=~led5;
led7=~led7;
}
}
control LED And buzzer
#include"reg51.h"
typedef unsigned int u16;
typedef unsigned char u8;
sbit led1=P2^0;
sbit led3=P2^2;
sbit led5=P2^4;
sbit led7=P2^6;
sbit beep=P1^5;
void delay(u16 i)
{
while(i--);
}
void Timer0Init()
{
TMOD|=0X01;
TH0=0XFC;
TL0=0X18;
EA=1;
TR0=1;// Overflow interrupt request flag bit
ET0=1;// Interrupt allow bit
}
void main()
{
Timer0Init();
while(1);
}
void Timer0() interrupt 1
{
static u16 i;
TH0=0XFC;
TL0=0X18;
i++;
if(i==1000)
{
i=0;
led1=~led1;
led3=~led3;
led5=~led5;
led7=~led7;
beep=~beep;
delay(10);
}
}
边栏推荐
- Design and development of biological instruments
- Fundamentals of Electronic Technology (III)__ Logic gate symbols in Chapter 5
- 【順利畢業】[1]-遊覽 [學生管理信息系統]
- UCI and data multiplexing are transmitted on Pusch - determine the bit number of harqack, csi1 and csi2 (Part II)
- 2021-01-03
- Getting started with JMX, MBean, mxbean, mbeanserver
- Getting started with shell programming
- CEF download, compile project
- 学习开发没有捷径,也几乎不存在带路会学的快一些的情况
- Intelligent home design and development
猜你喜欢

Error output redirection

Stm32f407 key interrupt

STM32 interrupt priority management

JS基础-原型原型链和宏任务/微任务/事件机制

Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()

Seven sorting of ten thousand words by hand (code + dynamic diagram demonstration)

UCI and data multiplexing are transmitted on Pusch - Part I

How MySQL modifies null to not null

STM32 interrupt switch

How does the memory database give full play to the advantages of memory?
随机推荐
MySQL Data Definition Language DDL common commands
嵌入式系统没有特别明确的定义
Install local sources using yum
[successful graduation] [1] - visit [student management information system]
Assignment to '*' form incompatible pointer type 'linkstack' {aka '*'} problem solving
当你需要使用STM32某些功能,而51实现不了时, 那32自然不需要学
2021-09-26
[combinatorics] Introduction to Combinatorics (context of combinatorics | skills of combinatorics | thought of combinatorics 1: one-to-one correspondence)
没有多少人能够最终把自己的兴趣带到大学毕业上
uniapp 实现微信小程序全局分享及自定义分享按钮样式
All processes of top ten management in project management
03 FastJson 解决循环引用
手机都算是单片机的一种,只不过它用的硬件不是51的芯片
Project cost management__ Plan value_ Earned value_ Relationship among actual cost and Countermeasures
【顺利毕业】[1]-游览 [学生管理信息系统]
Project scope management__ Scope management plan and scope specification
GPIO port details, Hal library operation keys
Development of electrical fire system
Fundamentals of Electronic Technology (III)__ Fundamentals of circuit analysis__ Basic amplifier operating principle
Stm32f04 clock configuration