光立方呼吸灯程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include

#define uint unsigned int

#define uchar unsigned char

int i=0;

uchar code table[]={

0,0,1,2,3,4,5,6,7,8,9,10,

11,12,13,14,15,16,17,18,

19,20,21,22,23,24,25,26,27,

28,29,30,31,32,33,34,35,36,

37,38,39,40,41,42,43,44,45,

46,47,48,49,50,51,52,53,54,

55,56,57,58,59,60,61,62,63,

64,65,66,67,68,69,70,71,72,

73,74,75,76,77,78,79,80,81,82,

83,84,85,86,87,88,89,90,91,

92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109, 110,111,112,113,114,115,116,117,118,119,120,121,122,123,124}; void delay(uint z)

{

uint x,y;

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

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

}

void light1(uchar num1)

{

uchar j;

P2=0xff;

P1=0x00;

P2=0x00;

j = table[num1];

delay(j);

P2=0xff;

P1=0xff;

P2=0x00;

delay(126-j);

}

void light2(uchar num2)

{

uchar j;

P2=0xff;

P1=0xff;

P2=0x00;

j = table[num2];

delay(j);

P2=0xff;

P1=0x00;

P2=0x00;

delay(126-j);

}

void main()

{

while(1)

{ for(i=0;i<126;i++)

{

light2(i);

}

P2=0xff;

P1=0xff;

P2=0x00;

delay(100);

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

{

light1(i);

}

}

}

相关文档
最新文档