当前位置:网站首页>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);
}
}
边栏推荐
- Chromium Embedded Framework (CEF) 介绍
- Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()
- Gpiof6, 7, 8 configuration
- Idea remote breakpoint debugging jar package project
- Vector processor 9_ Basic multilevel interconnection network
- Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
- Project scope management__ Scope management plan and scope specification
- UCI and data multiplexing are transmitted on Pusch (Part 4) --small block lengths
- Epollet lessons
- When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn
猜你喜欢

单片机职业发展:能做下去的都成牛人了,熬不动就辞职或者改行了

Gpiof6, 7, 8 configuration
C language enumeration type
![Successful graduation [2] - student health management system function development...](/img/91/72cdea3eb3f61315595330d2c9016d.png)
Successful graduation [2] - student health management system function development...

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

对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门

Electronic product design

Not many people can finally bring their interests to college graduation

CEF下载,编译工程

Fundamentals of Electronic Technology (III)__ Fundamentals of circuit analysis__ Basic amplifier operating principle
随机推荐
STM32 interrupt priority management
When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn
There is no specific definition of embedded system
Fundamentals of Electronic Technology (III)_ Chapter 2 principle of amplification circuit__ Crystal triode and field effect triode
当你需要使用STM32某些功能,而51实现不了时, 那32自然不需要学
Assignment to '*' form incompatible pointer type 'linkstack' {aka '*'} problem solving
The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
Matlab reads hexadecimal numbers and converts them into signed short
[CSDN] C1 training problem analysis_ Part IV_ Advanced web
Project cost management__ Plan value_ Earned value_ Relationship among actual cost and Countermeasures
端午节快乐!—— canvas写的粽子~~~~~
Which language should I choose to program for single chip microcomputer
You need to use MySQL in the opening experiment. How can you forget the basic select statement? Remedy is coming~
【順利畢業】[1]-遊覽 [學生管理信息系統]
Fundamentals of Electronic Technology (III)__ Chapter 1 resistance of parallel circuit
Vector processor 9_ Basic multilevel interconnection network
There is no shortcut to learning and development, and there is almost no situation that you can learn faster by leading the way
[csdn] C1 analyse des questions de formation Partie III Bar _ JS Foundation
In third tier cities and counties, it is difficult to get 10K after graduation
新系列单片机还延续了STM32产品家族的低电压和节能两大优势