电路原理图如下:
元件清单:
名称 数量 规格/型号 备注
万能板 3 18*30cm
单片机STC15F2K60S2 1 DIP40 除非你会改程序,否则请勿擅自更换
74hc154 4 宽窄两种封装均可
40P IC座 1
24P IC座 4
电解电容47uF 1
104电容 1
拨动开关 1
铜柱(含螺母) 4 M3*100mm
灯珠 540 2*5*7mm雾状 颜色自选
弯排针 1 每组40P
直排针 8 每组40P
白色飞线 2 若干
USB转TTL下载器 1 PL2303系列或CH340系列
母对母杜邦线 3 每组40P
母对公杜邦线 1 每组40P
微动开关 1
单片机源程序如下:
- /*作者:风铃 */
- #include"STC15F2K60S2.h"
- #include"intrins.h"
- #include"basic.h"
- #define SET 0x00
- #define CLR 0x00
- #define Segs P0
- #define Out P1
- sbit Rest=P3^0;
- void IO_int();
- void Timer1Init(void);
- Byte code table[]={
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
- };
- Byte code Segs_tab[]={
- 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
- 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
- 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
- 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,
- };
- void Timer0Init(void);
- unsigned char Anm1=0;
- unsigned int End,Anm=0;
- void main()
- {
- EA=1;
- End=sizeof(table);
- IO_int();
- Timer0Init();
- while(1)
- {
- if(Rest==0)IAP_CONTR=0x60;
- if(Anm>End)Anm=0;
-
- Segs=Segs_tab[Anm1];
- Out=table[Anm1+Anm];
- }
- }
- void IO_int()
- {
- P0M1=0x00;
- P0M0=0x00;
- P1M1=0x00;
- P1M0=0xff;
- }
- void Timer0Init(void) //100微秒@22.1184MHz
- {
- AUXR |= 0x80; //定时器时钟1T模式
- TMOD &= 0xF0; //设置定时器模式
- TL0 = 0x5C; //设置定时初值
- TH0 = 0xF7; //设置定时初值
- TF0 = 0; //清除TF0标志
- ET0=1;
- TR0 = 1; //定时器0开始计时
- }
- void delay() interrupt 1
- {
- TR0=0;
- Anm1=Anm1+1;
- if(Anm1>63)Anm1=0;
- Out=CLR;
- Segs=0xff;
- TR0=1;
- }
复制代码
所有资料51hei提供下载:
8x8x8光立方.7z
(315.52 KB, 下载次数: 38)
|