想做一个4*4的光立方,但是看不懂程序,请大神指点
时间:10-02
整理:3721RD
点击:
#include <reg52.h>
#include <intrins.h>
#include <string.h>
#include "Binary.h"
#define uint unsigned int
#define uchar unsigned char
#define LED P0
#define FLOOR P2
/*í?D?±í*/
uchar code table[16]=
{
B0000,B0000,B0000,B0000, //2?1
B0000,B0000,B0000,B0000, //2?2
B0000,B0000,B0000,B0000, //2?3
B0000,B0000,B0000,B0000, //2?4
};
/*′????óê±oˉêy*/
void delay(uint xms)
{
uint i,j;
for(i = xms ; i > 0 ; i--)
for(j=150;j > 0;j--);
}
/*ᢷ?ì?é¨?è*/
void Cube_display(uchar array[],uint delay_time)
{
uchar floor_temp;
uchar num;
for(;delay_time > 0;delay_time--)
{
for(num = 0,floor_temp = 0x01;num < 8;num++)
{
FLOOR = ~floor_temp;
LED = (~array[num]) | 0xf0;
delay(1);
LED = 0xff;
floor_temp = floor_temp << 1;
}
for(num = 8,floor_temp = 0x01;num < 16;num++)
{
FLOOR = ~floor_temp;
LED = (~(array[num]) << 4) | 0x0f;
delay(1);
LED = 0xff;
floor_temp = floor_temp << 1;
}
}
}
扫描部分不懂,能加个好友吗
#include <intrins.h>
#include <string.h>
#include "Binary.h"
#define uint unsigned int
#define uchar unsigned char
#define LED P0
#define FLOOR P2
/*í?D?±í*/
uchar code table[16]=
{
B0000,B0000,B0000,B0000, //2?1
B0000,B0000,B0000,B0000, //2?2
B0000,B0000,B0000,B0000, //2?3
B0000,B0000,B0000,B0000, //2?4
};
/*′????óê±oˉêy*/
void delay(uint xms)
{
uint i,j;
for(i = xms ; i > 0 ; i--)
for(j=150;j > 0;j--);
}
/*ᢷ?ì?é¨?è*/
void Cube_display(uchar array[],uint delay_time)
{
uchar floor_temp;
uchar num;
for(;delay_time > 0;delay_time--)
{
for(num = 0,floor_temp = 0x01;num < 8;num++)
{
FLOOR = ~floor_temp;
LED = (~array[num]) | 0xf0;
delay(1);
LED = 0xff;
floor_temp = floor_temp << 1;
}
for(num = 8,floor_temp = 0x01;num < 16;num++)
{
FLOOR = ~floor_temp;
LED = (~(array[num]) << 4) | 0x0f;
delay(1);
LED = 0xff;
floor_temp = floor_temp << 1;
}
}
}
扫描部分不懂,能加个好友吗
我也看不懂,希望能有人帮助!