#include<reg51.h> #include "intrins.h" //包含crol左移函数,cror右移函数. #include "math.h"
void delay02s() //延时0.2秒子程序
{ unsigned char m,n,s; for(m=5;m>0;m--) for(n=20;n>0;n--) for(s=248;s>0;s--); }
void main(void)
{ while (1) {unsigned char i,j,a,b; for( j=8;j>0;j--) { {unsigned char LED1=0x80; for(i=0;i<j;i++) { LED1=_crol_(LED1,1); //移到P1^0 a=pow(2,8)-pow(2,j); P1=LED1 | a; //只亮P1^0,此时a=0,藕合尾灯; delay02s(); b=pow(2,j)-1; LED1=LED1 & b; //去藕合; } } } } } 我在实验板上通过了.搞了三天,O,yeah!
|