- 博客(0)
- 资源 (2)
- 收藏
- 关注
计时器举一反三.pdsprj
初学者必备 动态链接的定时器
#include <reg51.h>
unsigned char count=0;
unsigned char miao=0;
sbit P2_7=P2^7;
sbit P1_2=P1^2;
sbit P1_3=P1^3;
void timer_1() interrupt 3
{
TH1 = ( 65536-50000 )/256;
TL1 = ( 65536-50000 )%256;
count++;
if(count==20)
{
count=0;
miao++;
if(miao==100)miao=0;
}
}
void disp (unsigned char i)
{
unsigned int j;
unsigned char led[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
P1_2=0;
P1_3=0;
P0=led[i/10];
P1_2=1;
for(j=0;j<100;j++);
P1_2=0;
P1_3=0;
P0=led[i%10];
P1_3=1;
for(j=0;j<100;j++);
}
2020-07-02
交通灯.pdsprj
仅供初学者参考
#include <reg51.h>
unsigned char t0,t1;
void delay0_5s1()
{
for (t0=0;t0<10;t0++)
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR1=1;
while(!TF1);
TF1=0;}
}
void delay_t1(unsigned char t)
{
for (t1=0;t1<t;t1++)
delay0_5s1();
}
void int_0() interrupt 0
{
unsigned char i,j,k,l,m;
i=P1;
j=t0;
k=t1;
l=TH1;
m=TL1;
P1=0xdb;
delay_t1(20);
P1=i;
t0=j;
t1=k;
TH1=l;
TL1=m;
}
2020-07-02
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人