|
#include <reg52.h> #define uint unsigned int #define uchar unsigned char void delay(uint z); void left(int x); void main() { IE=0x81; TCON=0x01; P1=0x00; while(1) { delay(250); P1=~P1; } } void delay(uint z) { uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void left(int x) { int i,j; for(i=0;i<x;i++) { P1=0xfe; for(j=0;j<7;j++) { delay(250); P1=(P1<<1)|0x01; } delay(250); } } void my_int0(void) interrupt 0 { unsigned saveP1=P1; left(3); P1=saveP1;//LED }
|
|