光立方呼吸灯程序
时间:10-02
整理:3721RD
点击:
#include<reg52.h>
#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);
}
}
}
#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);
}
}
}
好吧。也在试着做光立方,多交流啊
嗯嗯,好的。我的扣扣2471735791
我做看看!不过谢谢小编分享
LZ,有没有原理图分享下啊?非常想要啊
感谢啊
唉,成为伸手party了
没原理图 用不着啊小编
跪求原理图还有实物图。
收了
谢谢小编的分享
看看!
就是 也没原理图哎~~~~~~~
有转换成HEX格式的就更好了