当前位置:网站首页>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);
}
}
边栏推荐
- How does the memory database give full play to the advantages of memory?
- Error output redirection
- 自動裝箱與拆箱了解嗎?原理是什麼?
- 对于新入行的同学,如果你完全没有接触单片机,建议51单片机入门
- Basic knowledge of MySQL database (an introduction to systematization)
- Getting started with JMX, MBean, mxbean, mbeanserver
- [graduation successful] [1] - tour [Student Management Information System]
- Project cost management__ Plan value_ Earned value_ Relationship among actual cost and Countermeasures
- The cyclic shift of PUCCH in NR channel is generated by MATLAB
- STM32 general timer 1s delay to realize LED flashing
猜你喜欢
Fundamentals of Electronic Technology (III)__ Chapter 1 resistance of parallel circuit
The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
Nr--- Pusch I: sorting out the agreement process
Stm32-hal library learning, using cubemx to generate program framework
[combinatorics] Introduction to Combinatorics (combinatorial thought 2: mathematical induction | mathematical induction promotion | multiple induction thought)
PRACH --- originator
[CSDN] C1 training problem analysis_ Part II_ Web Foundation
STM32 serial port usart1 routine
When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn
MySQL Data Definition Language DDL common commands
随机推荐
The new series of MCU also continues the two advantages of STM32 product family: low voltage and energy saving
Qt QComboBox QSS样式设置
Fundamentals of Electronic Technology (III)__ Chapter 1 resistance of parallel circuit
STM32 general timer 1s delay to realize LED flashing
单片机学到什么程度能找到工作,这个标准不好量化
[combinatorics] Introduction to Combinatorics (combinatorial thought 2: mathematical induction | mathematical induction promotion | multiple induction thought)
Development of electrical fire system
编程思想比任何都重要,不是比谁多会用几个函数而是比程序的理解
Fundamentals of Electronic Technology (III)_ Integrated operational amplifier and its application__ Basic arithmetic circuit
Shell logic case
Project cost management__ Topic of comprehensive calculation
Epoll read / write mode in LT and et modes
【力扣刷题笔记(二)】特别技巧,模块突破,45道经典题目分类总结,在不断巩固中精进
【順利畢業】[1]-遊覽 [學生管理信息系統]
[CSDN] C1 training problem analysis_ Part II_ Web Foundation
Error output redirection
STM32 serial port usart1 routine
Project cost management__ Cost management technology__ Article 7 completion performance index (tcpi)
开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~
[keil5 debugging] warning:enumerated type mixed with other type