当前位置:网站首页>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);
}
}
边栏推荐
- Exception handling of arm
- All processes of top ten management in project management
- I didn't think so much when I was in the field of single chip microcomputer. I just wanted to earn money to support myself first
- 01仿B站项目业务架构
- 內存數據庫究竟是如何發揮內存優勢的?
- 自动装箱与拆箱了解吗?原理是什么?
- [CSDN] C1 training problem analysis_ Part II_ Web Foundation
- Successful graduation [3]- blog system update...
- 没有多少人能够最终把自己的兴趣带到大学毕业上
- [CSDN]C1訓練題解析_第三部分_JS基礎
猜你喜欢

How MySQL modifies null to not null

el-table X轴方向(横向)滚动条默认滑到右边

Electronic product design

Fundamentals of Electronic Technology (III)__ Logic gate symbols in Chapter 5

UCI and data multiplexing are transmitted on Pusch (Part VI) -- LDPC coding

单片机学到什么程度能找到工作,这个标准不好量化

Comment la base de données mémoire joue - t - elle l'avantage de la mémoire?

NR PUCCH format0 sequence generation and detection mechanism

When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn

Development of fire power monitoring system
随机推荐
[CSDN]C1訓練題解析_第三部分_JS基礎
Learn the contents of 5g toolbox supporting NR through the NR resources provided by MATLAB
Fundamentals of Electronic Technology (III)__ Fundamentals of circuit analysis__ Basic amplifier operating principle
01仿B站项目业务架构
You need to use MySQL in the opening experiment. How can you forget the basic select statement? Remedy is coming~
SSB Introduction (PbCH and DMRs need to be supplemented)
PRACH --- originator
PIP references domestic sources
MySQL的简单使用(增删改查)
Fundamentals of Electronic Technology (III)__ Logic gate symbols in Chapter 5
顺利毕业[2]-学生健康管理系统 功能开发中。。。
Simple use of MySQL (addition, deletion, modification and query)
Design and development of biological instruments
Basic knowledge of MySQL database (an introduction to systematization)
(1) 什么是Lambda表达式
【男保姆式】教你打开第一个微信小程序
Vector processor 9_ Basic multilevel interconnection network
STM32 general timer 1s delay to realize LED flashing
[graduation successful] [1] - tour [Student Management Information System]
在三线城市、在县城,很难毕业就拿到10K