当前位置:网站首页>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);
}
}
边栏推荐
- The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
- 2.Elment Ui 日期选择器 格式化问题
- [CSDN]C1训练题解析_第二部分_Web基础
- 在三线城市、在县城,很难毕业就拿到10K
- Fundamentals of Electronic Technology (III)__ Chapter 6 combinational logic circuit
- Emballage automatique et déballage compris? Quel est le principe?
- el-table X轴方向(横向)滚动条默认滑到右边
- Assignment to '*' form incompatible pointer type 'linkstack' {aka '*'} problem solving
- Which language should I choose to program for single chip microcomputer
- Definition and use of enum in C language
猜你喜欢

学习开发没有捷径,也几乎不存在带路会学的快一些的情况

Runtime.getRuntime().gc() 和 Runtime.getRuntime().runFinalization() 的区别

JMX、MBean、MXBean、MBeanServer 入门
![Successful graduation [2] - student health management system function development...](/img/91/72cdea3eb3f61315595330d2c9016d.png)
Successful graduation [2] - student health management system function development...

IDEA远程断点调试jar包项目

Blue Bridge Cup for migrant workers majoring in electronic information engineering

CEF下载,编译工程
C language enumeration type

Electronic product design, MCU development, circuit cloning

MySQL Data Definition Language DDL common commands
随机推荐
Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
STM32 port multiplexing and remapping
The third paper of information system project manager in soft examination
在三线城市、在县城,很难毕业就拿到10K
MYSQL数据库底层基础专栏
干单片机这一行的时候根本没想过这么多,只想着先挣钱养活自己
Simple use of MySQL (addition, deletion, modification and query)
Successful graduation [3]- blog system update...
UCI and data multiplexing are transmitted on Pusch (Part VI) -- LDPC coding
01仿B站项目业务架构
Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()
Development of fire evacuation system
An executable binary file contains more than machine instructions
The cyclic shift of PUCCH in NR channel is generated by MATLAB
【順利畢業】[1]-遊覽 [學生管理信息系統]
没有多少人能够最终把自己的兴趣带到大学毕业上
【力扣刷题笔记(二)】特别技巧,模块突破,45道经典题目分类总结,在不断巩固中精进
学历是一张通行证,门票,你有了它,可以踏入更高层次的环境里
Notes on C language learning of migrant workers majoring in electronic information engineering
Matlab reads hexadecimal numbers and converts them into signed short