當前位置:編程學習大全網 - 編程軟體 - 用五壹單片機c語言編程,p1口控制八個發光二極管,,按鍵改變廣告燈的顯示方式,控制要求如下。1,正

用五壹單片機c語言編程,p1口控制八個發光二極管,,按鍵改變廣告燈的顯示方式,控制要求如下。1,正

#include<reg52.h>

#include<intrins.h>

#define uchar unsigned char

#define uint unsigned int

uchar t,temp,flag;

sbit key1=P3^4;

sbit key2=P3^5;

void delay(uint z)

{

uint x,y;

for(x=z;x>0;x--)

for(y=110;y>0;y--);

}

void init()

{

TMOD=0x10;

TH1=(65536-50000)/256;

TL1=(65536-50000)%256;

EA=1;

ET1=1;

TR1=1;

temp=0xfe;

}

void main()

{

init();

while(1)

{

P1=temp;

if(key1==0)

{

temp=0x55;

while(!key1)

{

t=0;

P1=temp;

}

}

if(key2==0)

{

temp=0;

while(!key2)

{

t=0;

P1=temp;

flag=1;

}

}

}

}

void timer1() interrupt 3

{

TH1=(65536-50000)/256;

TL1=(65536-50000)%256;

t++;

if(t==10)

{

t=0;

temp=_crol_(temp,1);

if(flag==1)

{

temp=0xff;

flag=0;

}

}

}

  • 上一篇:數控銑床GM代碼,只要銑床的,知道的說下、謝謝啦
  • 下一篇:加工中心攻絲不執行M29是怎麽回事?
  • copyright 2024編程學習大全網