当前位置:网站首页>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);
}
}
边栏推荐
- Nr-prach: access scenario and access process
- Oracle数据库 SQL语句执行计划、语句跟踪与优化实例
- [csdn] C1 analyse des questions de formation Partie III Bar _ JS Foundation
- 03 FastJson 解决循环引用
- Schematic diagram and connection method of six pin self-locking switch
- 01仿B站项目业务架构
- Install local sources using yum
- UCI and data multiplexing are transmitted on Pusch - Part I
- When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn
- STM32 interrupt priority management
猜你喜欢

Development of fire power monitoring system

STM32 serial communication principle

Design and development of biological instruments

How does the memory database give full play to the advantages of memory?

Shell logic case

Nr--- Pusch I: sorting out the agreement process

SSB Introduction (PbCH and DMRs need to be supplemented)

STM32 interrupt switch

An executable binary file contains more than machine instructions
![[graduation successful] [1] - tour [Student Management Information System]](/img/91/72cdea3eb3f61315595330d2c9016d.png)
[graduation successful] [1] - tour [Student Management Information System]
随机推荐
All processes of top ten management in project management
How does the memory database give full play to the advantages of memory?
Windows下MySQL的安装和删除
IDEA远程断点调试jar包项目
顺利毕业[3]-博客系统 更新中。。。
Seven sorting of ten thousand words by hand (code + dynamic diagram demonstration)
Which language should I choose to program for single chip microcomputer
Oracle数据库 SQL语句执行计划、语句跟踪与优化实例
Stm32f407 key interrupt
03 FastJson 解决循环引用
Design and development of biological instruments
Getting started with JMX, MBean, mxbean, mbeanserver
要選擇那種語言為單片機編寫程序呢
There is no shortcut to learning and development, and there is almost no situation that you can learn faster by leading the way
How MySQL modifies null to not null
UCI and data multiplexing are transmitted on Pusch - Part I
Comment la base de données mémoire joue - t - elle l'avantage de la mémoire?
GPIO port details, Hal library operation keys
[22 graduation season] I'm a graduate yo~
Stm32-hal library learning, using cubemx to generate program framework