8个灯以此点亮c语言程序,单片机流水灯C语言程序(8个灯,依次点亮每个灯,延时500MS)...

#include

#include

void delayms(unsigned char ms)

// 延时子程序

{

unsigned char i;

while(ms--)

{

for(i = 0; i < 120; i++);

}

}

main()

{

unsigned char led;

led = 0xfe;

p0 = led;

while(1)

{

delayms(250);

led = _crol_(led,1); //循环右移1位,点亮下一个led

p0 = led;

}

}

reg51.h中定义的sfr:

/* byte register */

sfr p0 = 0x80;

sfr p1 = 0x90;

sfr p2 = 0xa0;

sfr p3 = 0xb0;

sfr psw = 0xd0;

sfr acc = 0xe0;

sfr b = 0xf0;

sfr sp = 0x81;

sfr dpl = 0x82;

sfr dph = 0x83;

sfr pcon = 0x87;

sfr tcon = 0x88;

sfr tmod = 0x89;

sfr

你可能感兴趣的:(8个灯以此点亮c语言程序)