光立方电路原理图595 +程序代码
ATMEGA16端口SPI扩展例子及源代码(HC595,驱动四位数码管)
A TMEGA16端口扩展例子及源代码青岛科技大学树立学院王泽华说明:1、数码管为共阳极。
2、HC595两片,第一片锁存段码,第二片锁存位码。
3、外部晶振8MHz该图可放大观看,例如拷贝到剪切板,然后复制到画图软件中。
这样比较清楚4、PROTEUL下溶思位的选择如下图所示。
源代码如下:可直接拷贝编译运行。
/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */#define F_CPU 8000000UL/* 定义SPI端口数据方向寄存器*/#define DD_SS 4#define DD_MOSI 5#define DD_MISO 6#define DD_SCK 7/* 定义SPI端口数据寄存器*/#define DR_SS 4#include <avr/io.h>#include <util/delay.h>/* 共阳极段码*/const unsigned char SEG_CODE[]={0x03,0x9F,0x25,0x0D,0x99,0x49,0x41,0x1F,0x01,0x09}; /* 位码*/const unsigned char BIT_CODE[]={0x80,0x40,0x20,0x10};/* SPI端口初始化*/void SPI_master_init(){/* 定义SPI主机,SS线,MOSI线,SCK线为输出*/DDRB = (1<<DD_SS) | (1<<DD_MOSI) | (1<<DD_SCK);/* 打开SPI端口,设本机为SPI主机,SCK=FOSC/16 */SPCR = (1<<SPE) | (1<<MSTR) | (1<<SPR0);/* SPI工作于MODE4 */SPCR |= (1<<CPOL) | (1<<CPHA);}/* 传输,特别用于只发不收,例如2片HC595控制数码管显示,每次传输两字节,第一字节为位码,第二字节为段码*/void SPI_master_send(char *pData, int iDataLen){int i;char temp;/* 拉低SS引脚,告之从机,开始数据传输*/PORTB &= ~( 1<<DR_SS );/* 发送数据*/for( i=0; i<iDataLen; i++){SPDR = pData[i];/* 等待发送完成*/while( !( SPSR & (1<<SPIF) ) );/* 清标志寄存器SPIF WCOL */temp = SPSR;temp = SPDR;}/* 拉高SS引脚,完成一次通讯,对HC595,拉高后595将移位寄存器数据锁存入数据寄存器*/PORTB |= ( 1<<DR_SS );}int main(){unsigned char i;char cData[2];/* SPI端口初始化*/SPI_master_init();while(1){for(i=0; i<4; i++){/* 先关闭数码管,消隐*/cData[0] = BIT_CODE[i];cData[1] = 0xFF;SPI_master_send(cData,2);/* 发送显示的数据*/cData[0] = BIT_CODE[i];cData[1] = SEG_CODE[i];SPI_master_send(cData,2);_delay_ms(4);}}}。
proteus原理图及程序(74HC595级联点亮LED)
#include<intrins.h>//
#define uchar unsigned char
#define uint unsigned int
//--定义使用的IO口--//
sbit DS=P2^1;//串行数据输入
sbit SHCP=P2^0;//移位寄存器时钟输入,为低电平时将595数据清零
* *
*输出数据子程序*
* *
*********************************************************/
void Output(adata) //将移位寄存器内的数据锁存到输出寄存器并显示,adata为输出的数据
{
STCP=0;
_noቤተ መጻሕፍቲ ባይዱ_();
_nop_();
do
{ tmp=ch;
SHCP=0;
if((tmp&0x80)==0x80) //如果最高位是1
DS=1;
else
DS=0;
SHCP=1;
tmp=ch<<1; //左移
ch=tmp;
BitCounter--;
_nop_();
STCP=0;
}
while(BitCounter);
}
/********************************************************
* *
*输入数据子程序*
* *
*********************************************************/
void Input(uchar ch) //将显示数据送入74HC595内部移位寄存
ADC0804的详细控制程序和仿真(595芯片和四位一体数码管)图
仿真电路图,经过测试,没问题下面是上个图的分解图模拟电路:设计模拟电路的原因主要有以下两点1.由于外界信号的复杂性,使得传感器直接输出的电信号可能会存在一些问题(如不稳定),这些不稳定信号如果直接送到A/D 芯片进行采样,则最终结果可能使得最后的显示值来回乱跳,而无法确定待测的外界信号到底是多少。
因此,可能需要设计一套模拟电路对传感器输出的不稳定电信号进行滤波等处理,去除干扰,使得进入A/D 转换芯片的电压值为一个稳定的信号。
2.每一个A/D 转换芯片都有一个参考电压,只有输入的模拟电压值在这个参考电压的范围内才能进行正确的转换,例如:本试验将ADC0804芯片的参考电压设置成0V ~5V ,因此如果输入的电压值大于5V ,则转换出的结果永远为0xFF,若输入的电压值小于0V,则转换出的结果永远为0,这样便无法正确的还原出被测信号的大小。
基于上述原因,我们可能需要设计一套模拟电路,传感器的输出电压值进行一些变换(放大,缩小),使得送到A/D转换芯片的电压值在转换芯片的参考电压范围内。
A/D转换芯片:即模拟/数字转换芯片,它将输入的模拟电压信号转换成单片机等控制处理器能够识别的数字二进制形式。
处理器芯片:处理器芯片有很多中(比如51单片机,ARM或者是PC上的奔腾处理器,AMD处理器)这些处理器虽然架构不一样,但是有个共同的特点,就是它们能够运行程序,因此它们能通过程序对A/D芯片送入的二进制形式的电压值进行处理,通过运算将其还原成待测的外界信号值,控制显示部件(如LCD,八段数码管)将这个值显示出来。
例如:假如ADC0804输出的二进制值0x80,则根据A/D转换公式可以推出ADC0804的输入电压大小为(0x80/0x100)*5V=2.5V。
假设信号经过模拟电路缩小了8倍,则可以推出传感器的输出电压为2.5V*8=20V,再根据传感器的转换公式(一般手册会给出)即可得到输入的外界信号的值。
显示:显示的作用是将计算出的待测外界信号的值展示给测量人员,显示的形式有很多种,如LCD,八段数码管,上位机软件等。
单片机制作光立方资料(基于74hc595和573)
单片机制作光立方资料(基于74hc595和573)需要光立方资料的朋友,为了方便我就直接放这里了,需要的自取.制作需要一定的电子基础,和相当的动手实践能力以及毅力,做的事情并不难,需要的更多是耐心,如果连最基本的二极管三极管怎么用都不懂那我劝你还是多学习一下基础知识再做吧,不然非常吃力.建议制作立方之前把电路研究透彻再动手,不要求把原理搞懂,最起码要能看懂几根线怎么连接。
不然会做不下去的.如果觉得这个比较难可以先找个简单的作品做,感受一下成就感!推荐做个心形流水灯,可以帮助了解整个制作的流程,包括下载程序等等......有个相册是我做的流水灯,大家可以看看,做的第一个,有点不科学。
资料过几天整理好了就发.这个里面只有驱动部分电路,没有点阵部分的,点阵部分就是层共阴,列共阳,一共引出8x8+8 等于72 根线。
其中8x8 是选列,还一个8 是选层.自己最起码得知道单片机最小系统是什么,不然没办法做的。
简单的说就是电源,复位电路和晶振部分,这是最具代表性的最小系统电路图,只是针对一部分51 系列单片机.这两个图就看不懂就不要问别的东西了,先好好学习一下在做吧.这两个资料足够让你做出来了,程序里面有.573 接线比较规律,容易看懂,但是要接的线多595 的接线稍微复杂一点点,大家自己下载下来看吧具体的制作资料从论坛下载:51hei/bbs/dpj-19043-1.html 单片机用STC12C5A60S2,晶振12 左右即可,别的就随你们了.如果不懂就加153176062 和153176062 这两个群,有人教.这是我收集的所有资料,有200M+,大家可以下载下来研究研究. 51hei/bbs/dpj-19043-1.htmltips:感谢大家的阅读,本文由我司收集整编。
仅供参阅!。
光立方电路原理图
这是用595的电路,材料清单如下:1:8个74HC595(封装为DIP—16);2:2个74HC04(封装为DIP—14);3:2个30PF的瓷介电容;一个10UF的电解电容;一个220UF的电解电容;4:一块89C516(单片机);5:每个芯片配套的座子;6:24或者12MHZ的晶振;7:1个1K,1个10K(都是碳膜电阻);8:一个按键开关,3个按键;9:最好买600个灯,因为焊接的时候可能会损坏(颜色随便你自己选择);10:你可以考虑买4个铜柱;备注:上面的3个按键可以只要1个,另外2个是我设计的外部中断,你可以不用它;同时我自己有开发板,所以我没有设计程序下载电路,全以最节省的方案为前提,你只要把单片机在开发板上下载好程序,再插到光立方上就好了。
同时画电路时每个芯片的电源引脚隐藏了,(单片机是20接负,40接正;595是8接负,16接正;7404是7接负,14接正。
),还有注意电解电容的极性。
关于你接电源的问题是你自己的事,我是在板子上面安装了一个USB的接口供电。
这是用573的电路,材料清单如下:1:8个74HC573(封装为DIP—20);2:2个74HC04(封装为DIP—14);3:2个30PF的瓷介电容;2个10UF的电解电容;一个220UF的电解电容;4:一块89C516(单片机);5:每个芯片配套的座子;6:24或者12MHZ的晶振;7:1个1K,2个10K,8个500欧(都是碳膜电阻);8:一个按键开关,1个按键;9:最好买600个灯,因为焊接的时候可能会损坏(颜色随便你自己选择);10:你可以考虑买4个铜柱;备注:画电路时每个芯片的电源引脚隐藏了,(单片机是20接负,40接正;573是10接负,20接正;7404是7接负,14接正。
),还有注意电解电容的极性。
关于你接电源的问题是你自己的事,我是在板子上面安装了一个USB的接口供电。
还有就是这个电路我没有画全,因为全部都一样的:就是:1:把8个573的2—9引脚对应接在一起;2:把8个573的11脚接在一起;总结:上面的2个电路,每个595或者573都有8个引脚没有接,那是用来接灯的负极的,8*8=64;7404的八个引脚是来接灯的正极的,8层就是8个引脚;同时最好把芯片按顺序依次的排列和连接,这样可以大大方便写程序。
光立方_毕业论文(含程序原理图实物图)
目录摘要 .......................................................................................................................................................... X XX 关键词 ...................................................................................................................................................... X XX 1绪论 . 02总体设计 (1)工作原理 (1)各模块方案选择与论证 (1)单片机主控制模块 (1)驱动模块 (1)显示模块 (1)图2-2 雾面乳型LED灯 (2)3 系统硬件电路设计与实现 (2)硬件电路设计 (2)单片机最小系统 (2)驱动模块的设计 (4)主程序设计 (8)系统调试 (9)硬件测试 (9)软件测试 (10)结果分析 (10)6结论 (11)Keywords (13)致谢语 (14) (16) (16)程序清单 (17)#include <> (17)#define uchar unsigned char (17)#define uint unsigned int (17)sbit p30 = P1^0; (17)sbit p31 = P1^1; (17)sbit p32 = P1^2; (17)sbit p33 = P1^3; (17)sbit p34 = P1^4; (17)sbit p35 = P1^5; (17)sbit p36 = P1^6; (17)sbit p37 = P1^7; (17)uchar display[8][8]; (17)/*rank:A,1,2,3,4,I,心,U*/ (17)uchar code table_cha[8][8]={0x51,0x51,0x51,0x4a,0x4a,0x4a,0x44,0x44,0x18,0x1c,0x18,0x18,0x18, 0x18,0x18,0x3c,0x3c,0x66,0x66,0x30,0x18,0xc,0x6,0xf6,0x3c,0x66,0x60,0x38,0x60,0x60 ,0x66,0x3c,0x30,0x38,0x3c,0x3e,0x36,0x7e,0x30,0x30,0x3c,0x3c,0x18,0x18,0x18,0x18,0 x3c,0x3c,0x66,0xff,0xff,0xff,0x7e,0x3c,0x18,0x18,0x66,0x66,0x66,0x66,0x66,0x66,0x7 e,0x3c}; (17)/*the "ideasoft"*/ (17)uchar code table_id[40]={0x81,0xff,0x81,0x00,0xff,0x81,0x81,0x7e,0x00,0xff,0x89,0x89,0x00,0xf 8,0x27,0x27,0xf8,0x00,0x8f,0x89,0x89,0xf9,0x00,0xff,0x81,0x81,0xff,0x00,0xff,0x09, 0x09,0x09,0x01,0x0,0x01,0x01,0xff,0x01,0x01,0x00}; (17)/*railway*/ (17)uchar code dat[128]={0x0,0x20,0x40,0x60,0x80,0xa0,0xc0,0xe0,0xe4,0xe8,0xec,0xf0,0xf4,0xf8,0xf c,0xdc,0xbc,0x9c,0x7c,0x5c,0x3c,0x1c,0x18,0x14,0x10,0xc,0x8,0x4,0x25,0x45,0x65,0x8 5,0xa5,0xc5,0xc9,0xcd,0xd1,0xd5,0xd9,0xb9,0x99,0x79,0x59,0x39,0x35,0x31,0x2d,0x29, 0x4a,0x6a,0x8a,0xaa,0xae,0xb2,0xb6,0x96,0x76,0x56,0x52,0x4e,0x6f,0x8f,0x93,0x73,0x 6f,0x8f,0x93,0x73,0x4a,0x6a,0x8a,0xaa,0xae,0xb2,0xb6,0x96,0x76,0x56,0x52,0x4e,0x25 ,0x45,0x65,0x85,0xa5,0xc5,0xc9,0xcd,0xd1,0xd5,0xd9,0xb9,0x99,0x79,0x59,0x39,0x35,0 x31,0x2d,0x29,0x0,0x20,0x40,0x60,0x80,0xa0,0xc0,0xe0,0xe4,0xe8,0xec,0xf0,0xf4,0xf8 ,0xfc,0xdc,0xbc,0x9c,0x7c,0x5c,0x3c,0x1c,0x18,0x14,0x10,0xc,0x8,0x4}; (17)/*railway 2*/ (17)uchar code dat2[28]={0x0,0x20,0x40,0x60,0x80,0xa0,0xc0,0xe0,0xe4,0xe8,0xec,0xf0,0xf4,0xf8,0xf c,0xdc,0xbc,0x9c,0x7c,0x5c,0x3c,0x1c,0x18,0x14,0x10,0xc,0x8,0x4}; (17)/*railway 3*/ (17)uchar code dat3[24]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x16,0x26,0x36,0x46,0x56,0x66,0x65,0x 64,0x63,0x62,0x61,0x60,0x50,0x40,0x30,0x20,0x10}; (17)/*3p char*/ (17)uchar codex3f,0x1f,0x0e,0x18,0x3c,0x7e,0xff,0x18,0x18,0x18,0x18}; (17)/*initializtion (17)That is to initialize the program (17)It is write to set the timer in c52 mcu (17)So the program can renovate the led_3d_cube in fixed time use the interrupt function.*/ (17)void sinter() (17){ (17)IE=0x82; (17)TCON=0x01; (17)TH0=0xc0; (17)TL0=0; (17)TR0=1; (17)} (17)void delay5us(void) 误差 STC 1T (18){ (18)unsigned char a,b; (18)for(b=7;b>0;b--) (18)for(a=2;a>0;a--); (18)} (18)void delay(uint i) (18){ (18)while (i--){ (18)delay5us();}12t的mcu 注释这个延时即可 (18)} (18)/*To judge the num bit*/ (18)uchar judgebit(uchar num,uchar b) (18){ (18)char n; (18)num=num&(1<<b); (18)if (num) (18)n=1; (18)else (18)n=0; (18)return n; (18)} (18)/*To figure out the round number*/ (18)uchar abs(uchar a) (18){ (18)uchar b; (18)b=a/10; (18)a=a-b*10; (18)if (a>=5) (18)b++; (18)/*To figure out the absolute value*/ (18)uchar abss(char a) (18){ (18)if (a<0) (18)a=-a; (18)return a; (18)} (18)/*The function can comparat the character (18)And remove the big one to the back.*/ (18)void max(uchar *a,uchar *b) (18){ (18)uchar t; (18)if ((*a)>(*b)) (18){ (18)t=(*a); (18)(*a)=(*b); (19)(*b)=t; (19)} (19)} (19)/*The function is to figure out the max number and return it.*/ (19)uchar maxt(uchar a,uchar b,uchar c) (19){ (19)if (a<b) (19)a=b; (19)if (a<c) (19)a=c; (19)return a; (19)} (19)void clear(char le) (19){ (19)uchar i,j; (19)for (j=0;j<8;j++) (19){ (19)for (i=0;i<8;i++) (19)display[j][i]=le; (19)} (19)} (19)void trailler(uint speed) (19){ (19)char i,j; (19)for (i=6;i>=-3;i--) (19){ (19)if (i>=0) (19)display[j][i]=display[j][i+1]; (19)} (19)if (i<4) (19){ (19)for (j=0;j<8;j++) (19)display[j][i+4]=0; (19)} (19)delay(speed); (19)} (19)} (19)void point(uchar x,uchar y,uchar z,uchar le) (19){ (19)uchar ch1,ch0; (19)ch1=1<<x; (19)ch0=~ch1; (20)if (le) (20)display[z][y]=display[z][y]|ch1; (20)else (20)display[z][y]=display[z][y]&ch0; (20)} (20)void type(uchar cha,uchar y) (20){ (20)uchar xx; (20)for (xx=0;xx<8;xx++) (20){ (20)display[xx][y]=table_cha[cha][xx]; (20)} (20)} (20)/*The first variable is the distance from the midpoint. (20)The second is the layer (20)the third is the flash speed of the time between each two point. (20)The forth is the enable io,it controls weather draw or claen.*/ (20)void cirp(char cpp,uchar dir,uchar le) (20){ (20)uchar a,b,c,cp; (20)if ((cpp<128)&(cpp>=0)) (20){ (20)if (dir) (20)cp=127-cpp; (20)else (20)cp=cpp; (20)a=(dat[cp]>>5)&0x07; (20)b=(dat[cp]>>2)&0x07; (20)c=7-c; (20)point (a,b,c,le); (20)} (20)} (20)void line(uchar x1,uchar y1,uchar z1,uchar x2,uchar y2,uchar z2,uchar le) (20){ (20)char t,a,b,c,a1,b1,c1,i; (20)a1=x2-x1; (20)b1=y2-y1; (20)c1=z2-z1; (20)t=maxt(abss(a1),abss(b1),abss(c1)); (20)a=x1*10; (20)b=y1*10; (21)c=z1*10; (21)a1=a1*10/t; (21)b1=b1*10/t; (21)c1=c1*10/t; (21)for (i=0;i<t;i++) (21){ (21)point(abs(a),abs(b),abs(c),le); (21)a+=a1; (21)b+=b1; (21)c+=c1; (21)} (21)point(x2,y2,z2,le); (21)} (21)void box(uchar x1,uchar y1,uchar z1,uchar x2,uchar y2,uchar z2,uchar fill,uchar le) (21){ (21)uchar i,j,t=0; (21)max(&x1,&x2); (21)max(&y1,&y2); (21)max(&z1,&z2); (21)for (i=x1;i<=x2;i++) (21)t|=1<<i; (21)if (!le) (21)t=~t; (21)if (fill) (21){ (21)if (le) (21){ (21)for (i=z1;i<=z2;i++) (21){ (21)} (21)} (21)else (21){ (21)for (i=z1;i<=z2;i++) (21){ (21)for (j=y1;j<=y2;j++) (21)display[j][i]&=t; (21)} (21)} (21)} (21)else (21){ (22)if (le) (22){ (22)display[y1][z1]|=t; (22)display[y2][z1]|=t; (22)display[y1][z2]|=t; (22)display[y2][z2]|=t; (22)} (22)else (22){ (22)display[y1][z1]&=t; (22)display[y2][z1]&=t; (22)display[y1][z2]&=t; (22)display[y2][z2]&=t; (22)} (22)t=(0x01<<x1)|(0x01<<x2); (22)if (!le) (22)t=~t; (22)if (le) (22){ (22)for (j=z1;j<=z2;j+=(z2-z1)) (22){ (22)for (i=y1;i<=y2;i++) (22)display[i][j]|=t; (22)} (22)for (j=y1;j<=y2;j+=(y2-y1)) (22){ (22)for (i=z1;i<=z2;i++) (22)display[j][i]|=t; (22)} (22)} (22)for (j=z1;j<=z2;j+=(z2-z1)) (22){ (22)for (i=y1;i<=y2;i++) (22){ (22)display[i][j]&=t; (22)} (22)} (22)for (j=y1;j<=y2;j+=(y2-y1)) (22){ (22)for (i=z1;i<=z2;i++) (22){ (23)display[j][i]&=t; (23)} (23)} (23)} (23)} (23)} (23)void box_apeak_xy(uchar x1,uchar y1,uchar z1,uchar x2,uchar y2,uchar z2,uchar fill,uchar le) (23){ (23)uchar i; (23)max(&z1,&z2); (23)if (fill) (23){ (23)for (i=z1;i<=z2;i++) (23){ (23)line (x1,y1,i,x2,y2,i,le); (23)} (23)} (23)else (23){ (23)line (x1,y1,z1,x2,y2,z1,le); (23)line (x1,y1,z2,x2,y2,z2,le); (23)line (x2,y2,z1,x2,y2,z2,le); (23)line (x1,y1,z1,x1,y1,z2,le); (23)} (23)} (23)void poke(uchar n,uchar x,uchar y) (23){ (23)uchar i; (23)for (i=0;i<8;i++) (23){ (23)point(x,y,i,judgebit(n,i)); (23)void boxtola(char i,uchar n) (23){ (23)if ((i>=0)&(i<8)) (23){ (23)poke(n,0,7-i); (23)} (23)if ((i>=8)&(i<16)) (23){ (23)poke(n,i-8,0); (23)} (24)if ((i>=16)&(i<24)) (24){ (24)poke(n,7,i-16); (24)} (24)} (24)void rolldisplay(uint speed) (24){ (24)uchar j; (24)char i,a; (24)for (i=23;i>-40;i--) (24){ (24)for (j=0;j<40;j++) (24){ (24)a=i+j; (24)if ((a>=0)&(a<24)) (24)boxtola(a,table_id[j]); (24)} (24)delay(speed); (24)} (24)} (24)void roll_apeak_yz(uchar n,uint speed) (24){ (24)uchar i; (24)switch(n) (24){ (24)case 1: (24)for (i=0;i<7;i++) (24){ (24)display[i][7]=0; (24)display[7][6-i]=255; (24)delay(speed); (24)}; (24)break; (24){ (24)display[7][7-i]=0; (24)display[6-i][0]=255; (24)delay(speed); (24)}; (24)break; (24)case 3: (24)for (i=0;i<7;i++) (25){ (25)display[7-i][0]=0; (25)display[0][i+1]=255; (25)delay(speed); (25)}; (25)break; (25)case 0: (25)for (i=0;i<7;i++) (25){ (25)display[0][i]=0; (25)display[i+1][7]=255; (25)delay(speed); (25)}; (25)} (25)} (25)void roll_apeak_xy(uchar n,uint speed) (25){ (25)uchar i; (25)switch(n) (25){ (25)case 1: (25)for (i=0;i<7;i++) (25){ (25)line(0,i,0,0,i,7,0); (25)line(i+1,7,0,i+1,7,7,1); (25)delay(speed); (25)}; (25)break; (25)case 2: (25)for (i=0;i<7;i++) (25){ (25)line(i,7,0,i,7,7,0); (25)line(7,6-i,0,7,6-i,7,1); (25)delay(speed); (25)}; (25)for (i=0;i<7;i++) (25){ (25)line(7,7-i,0,7,7-i,7,0); (25)line(6-i,0,0,6-i,0,7,1); (25)delay(speed); (25)}; (26)break; (26)case 0: (26)for (i=0;i<7;i++) (26){ (26)line(7-i,0,0,7-i,0,7,0); (26)line(0,i+1,0,0,i+1,7,1); (26)delay(speed); (26)}; (26)} (26)} (26)void roll_3_xy(uchar n,uint speed) (26){ (26)uchar i; (26)switch(n) (26){ (26)case 1: (26)for (i=0;i<8;i++) (26){ (26)box_apeak_xy (0,i,0,7,7-i,7,1,1); (26)delay(speed); (26)if (i<7) (26)box_apeak_xy (3,3,0,0,i,7,1,0); (26)}; (26)break; (26)case 2: (26)for (i=0;i<8;i++) (26){ (26)box_apeak_xy (7-i,0,0,i,7,7,1,1); (26)delay(speed); (26)if (i<7) (26)box_apeak_xy (3,4,0,i,7,7,1,0); (26)}; (26)break; (26)case 3: (26)for (i=0;i<8;i++) (26){ (26)box_apeak_xy (0,i,0,7,7-i,7,1,1); (26)box_apeak_xy (4,4,0,7,7-i,7,1,0); (26)}; (26)break; (26)case 0: (26)for (i=0;i<8;i++) (27){ (27)box_apeak_xy (7-i,0,0,i,7,7,1,1); (27)delay(speed); (27)if (i<7) (27)box_apeak_xy (4,3,0,7-i,0,7,1,0); (27)}; (27)} (27)} (27)void trans(uchar z,uint speed) (27){ (27)uchar i,j; (27)for (j=0;j<8;j++) (27){ (27)for (i=0;i<8;i++) (27){ (27)display[z][i]>>=1; (27)} (27)delay(speed); (27)} (27)} (27)void tranoutchar(uchar c,uint speed) (27){ (27)uchar i,j,k,a,i2=0; (27)for (i=0;i<8;i++) (27){ (27)if (i<7) (27)box_apeak_xy (i+1,0,0,i+1,7,7,1,1); (27)box_apeak_xy (i2,0,0,i2,7,7,1,0); (27)a=0; (27)i2=i+1; (27)for (j=0;j<=i;j++) (27){ (27)a=a|(1<<j); (27)} (27)for (k=0;k<8;k++) (27){ (27)display[k][3]|=table_cha[c][k]&a; (27)display[k][4]|=table_cha[c][k]&a; (27)} (27)} (27)void transss() (28){ (28)uchar i,j; (28)for (i=0;i<8;i++) (28){ (28)for (j=0;j<8;j++) (28)display[i][j]<<=1; (28)} (28)} (28)/*From now on,the function below is to display the flash.*/ (28)void flash_1() (28){ (28)clear(0); (28)type(1,0); (28)delay(60000); (28)type(2,0); (28)delay(60000); (28)type(3,0); (28)delay(60000); (28)type(4,0); (28)delay(60000); (28)delay(60000); (28)clear(0); (28)rolldisplay(30000); (28)type(0,7); (28)delay(60000); (28)trailler(6000); (28)delay(60000); (28)} (28)void flash_2() (28){ (28)uchar i; (28)for (i=129;i>0;i--) (28){ (28)cirp(i-2,0,1); (28)delay(8000); (28)cirp(i-1,0,0); (28)} (28)delay(8000); (28)for (i=0;i<136;i++) (28){ (28)cirp(i-8,1,0); (29)} (29)delay(8000); (29)for (i=129;i>0;i--) (29){ (29)cirp(i-2,0,1); (29)delay(8000); (29)} (29)delay(8000); (29)for (i=0;i<128;i++) (29){ (29)cirp(i-8,1,0); (29)delay(8000); (29)} (29)delay(60000); (29)} (29)void flash_3() (29){ (29)char i; (29)for (i=0;i<8;i++) (29){ (29)box_apeak_xy(0,i,0,7,i,7,1,1); (29)delay(20000); (29)if (i<7) (29)box_apeak_xy(0,i,0,7,i,7,1,0); (29)} (29)for (i=7;i>=0;i--) (29){ (29)box_apeak_xy(0,i,0,7,i,7,1,1); (29)delay(20000); (29)if (i>0) (29)box_apeak_xy(0,i,0,7,i,7,1,0); (29)} (29)for (i=0;i<8;i++) (29){ (29)box_apeak_xy(0,i,0,7,i,7,1,1); (29)delay(20000); (29)if (i<7) (29)box_apeak_xy(0,i,0,7,i,7,1,0); (29)} (29)} (29)void flash_4() (29){ (30)an[j-7]=j; (30)for (i=0;i<=16;i++) (30){ (30)for (j=0;j<8;j++) (30){ (30)if ((an[j]<8)&(an[j]>=0)) (30)line(0,an[j],j,7,an[j],j,1); (30)} (30)for (j=0;j<8;j++) (30){ (30)if (((an[j]+1)<8)&(an[j]>=0)) (30)line(0,an[j]+1,j,7,an[j]+1,j,0); (30)} (30)for (j=0;j<8;j++) (30){ (30)if (an[j]>0) (30)an[j]--; (30)} (30)delay(15000); (30)} (30)for (j=0;j<8;j++) (30)an[j]=1-j; (30)for (i=0;i<=16;i++) (30){ (30)for (j=0;j<8;j++) (30){ (30)if ((an[j]<8)&(an[j]>=0)) (30)line(0,an[j],j,7,an[j],j,1); (30)} (30)for (j=0;j<8;j++) (30){ (30)if (((an[j]-1)<7)&(an[j]>0)) (30)line(0,an[j]-1,j,7,an[j]-1,j,0); (30)} (30)for (j=0;j<8;j++) (30){ (30)if (an[j]<7) (30)an[j]++; (30)} (30)delay(15000); (30)} (30)} (31)void flash_5() (31)char i=8,j,an[4]; (31)1 (31)for (j=7;j<11;j++) (31)an[j-7]=j; (31)while(i--) (31){ (31)for (j=0;j<4;j++) (31){ (31)if (an[j]<8) (31)box_apeak_xy(j,an[j],j,7-j,an[j],7-j,0,1); (31)if (an[j]<7) (31)box_apeak_xy(j,an[j]+1,j,7-j,an[j]+1,7-j,0,0); (31)} (31)for (j=0;j<4;j++) (31){ (31)if (an[j]>3) (31)an[j]--; (31)} (31)delay(a); (31)} (31)2 (31)i=3; (31)for (j=0;j<4;j++) (31)an[j]=5-j; (31)while(i--) (31){ (31)for (j=1;j<4;j++) (31){ (31)if (an[j]<4) (31)box_apeak_xy(j,an[j],j,7-j,an[j],7-j,0,1); (31)if (an[j]<3) (31)box_apeak_xy(j,an[j]+1,j,7-j,an[j]+1,7-j,0,0); (31)} (31)for (j=0;j<4;j++) (31){ (31)if (an[j]>0) (31)an[j]--; (31)} (31)delay(a); (31)} (32)3 (32)i=3; (32)for (j=1;j<4;j++) (32){ (32)for (j=1;j<4;j++) (32){ (32)if (an[j]>=0) (32)box_apeak_xy(j,an[j],j,7-j,an[j],7-j,0,1); (32)if (an[j]>0) (32)box_apeak_xy(j,an[j]-1,j,7-j,an[j]-1,7-j,0,0); (32)} (32)for (j=1;j<4;j++) (32){ (32)if (an[j]<3) (32)an[j]++; (32)} (32)delay(a); (32)} (32)4 (32)i=3; (32)for (j=0;j<4;j++) (32)an[j]=j+1; (32)while(i--) (32){ (32)for (j=1;j<4;j++) (32){ (32)if (an[j]>3) (32)box_apeak_xy(j,an[j],j,7-j,an[j],7-j,0,1); (32)if (an[j]>3) (32)box_apeak_xy(j,an[j]-1,j,7-j,an[j]-1,7-j,0,0); (32)} (32)for (j=0;j<4;j++) (32)an[j]++; (32)delay(a); (32)} (32)5 (32)i=3; (32)for (j=3;j<6;j++) (32)an[j-2]=j; (32)while(i--) (32){ (33)for (j=1;j<4;j++) (33){ (33)box_apeak_xy(j,an[j],j,7-j,an[j],7-j,0,1); (33)box_apeak_xy(j,an[j]+1,j,7-j,an[j]+1,7-j,0,0); (33)} (33)if (an[j]>3) (33)an[j]--; (33)} (33)delay(a); (33)} (33)6 (33)i=3; (33)for (j=0;j<4;j++) (33)an[j]=5-j; (33)while(i--) (33){ (33)for (j=1;j<4;j++) (33){ (33)if (an[j]<4) (33)box_apeak_xy(j,an[j],j,7-j,an[j],7-j,0,1); (33)if (an[j]<3) (33)box_apeak_xy(j,an[j]+1,j,7-j,an[j]+1,7-j,0,0); (33)} (33)for (j=0;j<4;j++) (33){ (33)if (an[j]>0) (33)an[j]--; (33)} (33)delay(a); (33)} (33)7 (33)i=3; (33)for (j=0;j<4;j++) (33)an[j]=3-j; (33)an[0]=2; (33)while(i--) (33){ (33)for (j=0;j<3;j++) (33){ (33)if (an[j]>=0) (33)box_apeak_xy(j,an[j],j,7-j,an[j],7-j,0,1); (34)if (an[j]>=0) (34)box_apeak_xy(j,an[j]+1,j,7-j,an[j]+1,7-j,0,0); (34)} (34)for (j=0;j<4;j++) (34){ (34)if (j<5-i) (34)an[j]--; (34)} (34)8 (34)i=10; (34)for (j=0;j<4;j++) (34)an[j]=j-2; (34)while(i--) (34){ (34)for (j=0;j<4;j++) (34){ (34)if (an[j]>=0) (34)box_apeak_xy(j,an[j],j,7-j,an[j],7-j,0,1); (34)if (an[j]>=0) (34)box_apeak_xy(j,an[j]-1,j,7-j,an[j]-1,7-j,0,0); (34)} (34)for (j=0;j<4;j++) (34){ (34)if (an[j]<7) (34)an[j]++; (34)} (34)delay(a); (34)} (34)} (34)void flash_6() (34){ (34)uchar i,j,k,z; (34)roll_apeak_yz(1,10000); (34)roll_apeak_yz(2,10000); (34)roll_apeak_yz(3,10000); (34)roll_apeak_yz(0,10000); (34)roll_apeak_yz(1,10000); (34)roll_apeak_yz(2,10000); (34)roll_apeak_yz(3,10000); (34)for (i=0;i<3;i++) (34){ (34)for (j=0;j<8;j++) (35){ (35)for (k=0;k<8;k++) (35){ (35)if ((table_3p[i][j]>>k)&1) (35){ (35)for (z=1;z<8;z++) (35){ (35)point (j,7-k,z,1); (35)delay(5000); (35)} (35)} (35)} (35)} (35)trans(7,15000); (35)} (35)} (35)void flash_7() (35){ (35)uchar i; (35)uint a=3000; (35)roll_apeak_yz(0,10000); (35)roll_apeak_yz(1,10000); (35)roll_apeak_yz(2,10000); (35)roll_apeak_yz(3,10000); (35)roll_apeak_yz(0,10000); (35)roll_apeak_yz(1,10000); (35)roll_apeak_yz(2,10000); (35)roll_apeak_yz(3,10000); (35)roll_apeak_yz(0,10000); (35)roll_apeak_yz(1,10000); (35)roll_apeak_yz(2,10000); (35)roll_apeak_xy(0,10000); (35)roll_apeak_xy(1,10000); (35)roll_apeak_xy(2,10000); (35)roll_apeak_xy(3,10000); (35)roll_apeak_xy(0,10000); (35)roll_apeak_xy(1,10000); (35)roll_apeak_xy(2,10000); (35)roll_apeak_xy(3,10000); (35)for (i=0;i<8;i++) (36){ (36)box_apeak_xy (0,i,0,7-i,i,7,1,1); (36)delay(a); (36)} (36)delay(30000); (36)roll_3_xy(0,a); (36)delay(30000); (36)roll_3_xy(1,a); (36)delay(30000); (36)roll_3_xy(2,a); (36)delay(30000); (36)roll_3_xy(0,a); (36)delay(30000); (36)roll_3_xy(1,a); (36)delay(30000); (36)roll_3_xy(2,a); (36)delay(30000); (36)roll_3_xy(3,a); (36)for (i=7;i>0;i--) (36){ (36)box_apeak_xy(i,0,0,i,7,7,1,0); (36)delay(a); (36)} (36)} (36)void flash_8() (36){ (36)uchar i; (36)for (i=5;i<8;i++) (36){ (36)tranoutchar(i,10000); (36)delay(60000); (36)delay(60000); (36)} (36)} (36)void flash_9() (36){ (36)char i; (36)uchar j,an[8],x,y,t,x1,y1; (36)for (i=0;i<8;i++) (36){ (36)box_apeak_xy (i,0,0,i,7,7,1,1); (36)if (i) (37)box_apeak_xy (i-1,0,0,i-1,7,7,1,0); (37)delay(10000); (37)} (37)roll_apeak_xy(3,10000); (37)roll_apeak_xy(0,10000); (37)roll_apeak_xy(1,10000); (37)for (i=0;i<7;i++) (37){ (37)line(6-i,6-i,0,6-i,6-i,7,1); (37)line(i,7,0,i,7,7,0); (37)delay(10000); (37)} (37)for (i=0;i<85;i++) (37){ (37)clear(0); (37)for (j=0;j<8;j++) (37){ (37)t=an[j]%28; (37)x=dat2[t]>>5; (37)y=(dat2[t]>>2)&0x07; (37)t=(an[j]-14)%28; (37)x1=dat2[t]>>5; (37)y1=(dat2[t]>>2)&0x07; (37)line(x,y,j,x1,y1,j,1); (37)} (37)for (j=0;j<8;j++) (37){ (37)if ((i>j)&(j>i-71)) (37)an[j]++; (37)} (37)delay(5000); (37)} (37)for (i=0;i<85;i++) (37){ (37)clear(0); (37)for (j=0;j<8;j++) (37){ (37)t=an[j]%28; (37)x=dat2[t]>>5; (37)y=(dat2[t]>>2)&0x07; (37)t=(an[j]-14)%28; (38)x1=dat2[t]>>5; (38)y1=(dat2[t]>>2)&0x07; (38)line(x,y,j,x1,y1,j,1); (38)} (38)for (j=0;j<8;j++) (38){ (38)if ((i>j)&(j>i-71)) (38)an[j]--; (38)} (38)delay(5000); (38)} (38)for (i=0;i<29;i++) (38){ (38)clear(0); (38)y=(dat2[t]>>2)&0x07; (38)t=(an[0]-14)%28; (38)x1=dat2[t]>>5; (38)y1=(dat2[t]>>2)&0x07; (38)box_apeak_xy(x,y,0,x1,y1,7,0,1); (38)box_apeak_xy(x,y,1,x1,y1,6,0,1); (38)an[0]++; (38)delay(5000); (38)} (38)for (i=0;i<16;i++) (38){ (38)clear(0); (38)t=an[0]%28; (38)x=dat2[t]>>5; (38)y=(dat2[t]>>2)&0x07; (38)t=(an[0]-14)%28; (38)x1=dat2[t]>>5; (38)y1=(dat2[t]>>2)&0x07; (38)box_apeak_xy(x,y,0,x1,y1,7,1,1); (38)an[0]--; (38)delay(5000); (38)} (38)for (i=0;i<8;i++) (38){ (38)line(i,i,0,0,0,i,0); (38)delay(5000); (39)} (39)for (i=1;i<7;i++) (39){ (39)line(i,i,7,7,7,i,0); (39)delay(5000); (39)} (39)for (i=1;i<8;i++) (39){ (39)clear(0); (39)box(7,7,7,7-i,7-i,7-i,0,1); (39)delay(10000); (39)} (39)for (i=1;i<7;i++) (39){ (39)clear(0); (39)box(0,0,0,7-i,7-i,7-i,0,1); (39)delay(10000); (39){ (39)clear(0); (39)box(0,0,0,i,i,i,0,1); (39)delay(10000); (39)} (39)for (i=1;i<7;i++) (39){ (39)clear(0); (39)box(7,0,0,i,7-i,7-i,0,1); (39)delay(10000); (39)} (39)for (i=1;i<8;i++) (39){ (39)box(7,0,0,7-i,i,i,1,1); (39)delay(10000); (39)} (39)for (i=1;i<7;i++) (39){ (39)clear(0); (39)box(0,7,7,7-i,i,i,1,1); (39)delay(10000); (39)} (39)} (39)void flash_10() (40){ (40)uchar i,j,an[4],x,y,t; (40)for (i=1;i<7;i++) (40){ (40)clear(0); (40)box(0,6,6,1,7,7,1,1); (40)box(i,6,6-i,i+1,7,7-i,1,1); (40)box(i,6,6,i+1,7,7,1,1); (40)box(0,6,6-i,1,7,7-i,1,1); (40)box(0,6-i,6,1,7-i,7,1,1); (40)box(i,6-i,6-i,i+1,7-i,7-i,1,1); (40)box(i,6-i,6,i+1,7-i,7,1,1); (40)box(0,6-i,6-i,1,7-i,7-i,1,1); (40)delay(30000); (40)} (40)for (i=0;i<4;i++) (40){ (40)an[i]=6*i; (40)} (40)clear(0); (40)for(j=0;j<4;j++) (40){ (40)t=an[j]%24; (40)x=dat3[t]>>4; (40)y=dat3[t]&0x0f; (40)box(x,y,0,x+1,y+1,1,1,1); (40)box(x,y,6,x+1,y+1,7,1,1); (40)} (40)for (j=0;j<4;j++) (40)an[j]++; (40)delay(10000); (40)} (40)for (i=0;i<35;i++) (40){ (40)clear(0); (40)for(j=0;j<4;j++) (40){ (40)t=an[j]%24; (40)x=dat3[t]>>4; (40)y=dat3[t]&0x0f; (40)box(x,y,0,x+1,y+1,1,1,1); (41)box(x,y,6,x+1,y+1,7,1,1); (41)} (41)for (j=0;j<4;j++) (41)an[j]--; (41)delay(10000); (41)} (41)for (i=0;i<35;i++) (41){ (41)clear(0); (41)for(j=0;j<4;j++) (41){ (41)t=an[j]%24; (41)x=dat3[t]>>4; (41)y=dat3[t]&0x0f; (41)box(x,0,y,x+1,1,y+1,1,1); (41)box(x,6,y,x+1,7,y+1,1,1); (41)} (41)for (j=0;j<4;j++) (41)an[j]++; (41)delay(10000); (41)} (41)clear(0); (41)for(j=0;j<4;j++) (41){ (41)t=an[j]%24; (41)x=dat3[t]>>4; (41)y=dat3[t]&0x0f; (41)box(x,0,y,x+1,1,y+1,1,1); (41)box(x,6,y,x+1,7,y+1,1,1); (41)} (41)for (j=0;j<4;j++) (41)an[j]--; (41)delay(10000); (41)} (41)for (i=6;i>0;i--) (41){ (41)clear(0); (41)box(0,6,6,1,7,7,1,1); (41)box(i,6,6-i,i+1,7,7-i,1,1); (41)box(i,6,6,i+1,7,7,1,1); (42)box(0,6,6-i,1,7,7-i,1,1); (42)box(0,6-i,6,1,7-i,7,1,1); (42)box(i,6-i,6-i,i+1,7-i,7-i,1,1); (42)box(i,6-i,6,i+1,7-i,7,1,1); (42)box(0,6-i,6-i,1,7-i,7-i,1,1); (42)delay(30000); (42)} (42)} (42)void flash_11() (42){ (42)uchar i,j,t,x,y; (42)uchar code daa[13]={0,1,2,0x23,5,6,7,6,5,0x23,2,1,0}; (42)for (j=0;j<5;j++) (42){ (42)for (i=0;i<13;i++) (42){ (42)if (daa[i]>>4) (42){ (42)t=daa[i]&0x0f; (42)line (0,0,t+1,0,7,t+1,1); (42)} (42)else (42)t=daa[i]; (42)line (0,0,t,0,7,t,1); (42)} (42)} (42)for (j=1;j<8;j++) (42){ (42)if (j>3) (42)t=4; (42)else (42)t=j; (42)for (i=0;i<24;i+=j) (42){ (42)x=dat3[i]>>4; (42)y=dat3[i]&0x0f; (42)box_apeak_xy(0,x,y,0,x+1,y+1,1,1); (42)transss(); (42)delay(10000); (42)} (42)} (42)for (j=1;j<8;j++) (43){ (43)if (j>3) (43)t=4; (43)else (43)t=j; (43)for (i=0;i<24;i+=j) (43){ (43)x=dat3[i]>>4; (43)y=dat3[i]&0x0f; (43)point (0,x,y,1); (43)transss(); (43)delay(10000); (43)} (43)} (43)} (43)void _P3(uchar x) (43){ (43)p30 = x&0x01; (43)p31 = (x&0x02)>>1; (43)p32 = (x&0x04)>>2; (43)p33 = (x&0x08)>>3; (43)p34 = (x&0x10)>>4; (43)p35 = (x&0x20)>>5; (43)p36 = (x&0x40)>>6; (43)p37 = (x&0x80)>>7; (43){ (43)sinter(); (43)while(1){ (43)clear(0); (43)/*play list*/ (43)flash_1(); (43)clear(0); (43)flash_2(); (43)flash_3(); (43)flash_4(); (43)flash_4(); (43)flash_5(); (43)flash_5(); (43)flash_6(); (43)flash_7(); (43)flash_8(); (43)flash_9(); (43)flash_10(); (43)clear (0); (43)flash_11(); (43)flash_9(); (43)flash_5(); (43)flash_7(); (44)flash_5(); (44)flash_6(); (44)flash_8(); (44)flash_9(); (44)flash_10(); (44)} (44)} (44)P0; 573 in (44)P1; uln2803 (44)P2; 573 LE (44)void print() interrupt 1 (44){ (44)uchar i; (44)static uchar layer=0; (44)P1=0; (44)for (i=0;i<8;i++) (44){ (44)P2=1<<i; (44)delay(3); (44)P0=display[layer][i]; (44)P1=1<<layer; (44)if (layer<7) (44)layer++; (44)else (44)layer=0; (44)TH0=0xc0; (44)TL0=0; (44)} (44)P0; 573 in p2 (44)P1; uln2803 p0 (44)P2; 573 LE p1 (44)void print() interrupt 1 (44){ (44)uchar i; (44)static uchar layer=0; (44)_P3(0); (44)for (i=0;i<8;i++) (44){ (44)P2=1<<i; (44)delay(3); (44)P0=display[layer][i]; (44)delay(3); (44)} (45)_P3(1<<layer); (45)if (layer<7) (45)layer++; (45)else (45)layer=0; (45)TH0=0xc0; (45)TL0=0; (45)} (45)void print() interrupt 1 (45){ (45)uchar i; (45)static uchar layer=0; (45)P0=0; (45)P1=0x00; (45)for (i=0;i<8;i++) (45){ (45)P1=0x00; (45)P2=display[layer][i]; (45)delay(3); (45)P1=1<<i;_crol_(0xfe,i) ; (45)。
光立方基于74hc595的上位机(取模软件)控制程序
{
if((!KEY1)&&(!KEY2))//当KEY1和KEY2同时按下时执行此语句
{
delay(10);//延时
if((!KEY1)&&(!KEY2)){while(!KEY2);hour++;} //确实有按键按下,则时加1,到24自动归0
}
if((!KEY1)&&(!KEY3))//当KEY1和KEY3同时按下时执行此语句
case 7: write595(tab1[sec%10]);break; //数据取余,显示秒个位
}
OE=0;//打开输出,输出595存储器数据
P2=~tab2[i];//位选输出,选通对应的时分秒数码管
delay(10);//调用延时子程序
OE=1;//关闭输出,同时具有消隐作用
}
}
/*………………时间调整函数………………….*/
光立方基于74hc595的上位机(取模软件)控制程序
#include<reg52.h> //头文件
#include<intrins.h>//头文件
#define uchar unsigned char//宏定义
sbit SHCP=P1^0;//595移位寄存器时钟,上升沿有效
sbit STCP=P1^1;//595存储器时钟,上升沿有效
sbit DS=P1^2;//数据输入端
sbit OE=P1^3;//数据输出端
sbit KEY1=P3^0;//组合按键
sbit KEY2=P3^1;//调时按键
sbit KEY3=P3^2;//调分按键
光立方电路原理图与其所需元件
{
daojishi();//倒计时7—0
for(j=0;j<50;j++)
{
suofang();//方框缩放
}
//xingdian();//星点
void xingdian()
{
uchar x,y,z;
for(z=0;z<8;z++)
for(y=0;y<8;y++)
{
for(x=0;x<8;x++)
{
if((y==0)||(y==2)||(y==4)||(y==6)||(y==1)||(y==3)||(y==5)||(y==7))
{
P1=y1[y];
5:每个芯片配套的座子;
6:24MHZ或者12MHZ的晶振;
7:1个1K,1个10K(都是碳膜电阻);
8:一个按键开关,3个按键;
9:最好买600个灯(一包也可以,比较便宜),因为焊接的时候可能会损坏,颜色随便你自己选择;
备注:上面的3个按键可以只要1个,另外2个是我设计的外部中断,你可以不用它;同时我自己有开发板,所以我没有设计程序下载电路,全以最节省的方案为前提,你只要把单片机在开发板上下载好程序,再插到光立方上就好了。同时画电路时每个芯片的电源引脚隐藏了,(595是8接负,16接正;7404是7接负,14接正。),还有注意电解电容的极性。我是在板子上面安装了一个USB的接口供电。
P2=z1[r];
Set595(x1[0]);
dis595();
}
}
}
for(e=0;e<8;e++)
{
for(r=0;r<8;r++)
基于74hc595n的光立方
首先上595光立方的原理图:1.单片机部分:2.按键和ULN2803部分:3.74hc595n部分:8个的样子:4.灯座部分:64个的样子:与灯座相连的电阻,可根据自己的LED来选。
只要不超过LED的耐压值即可。
然后是参考的PCB图:芯片连接部分:先来讲解一下原理图:首先是51单片机的由晶振电路和复位电路组成的单片机的最小系统。
74hc595的8个输出脚与灯座相连,8个595的Ds、STcp、SHcp 接到一起,分别接到单片机的IO口。
8个595的MR直接接到VCC。
595的控制引脚OE分别与单片机IO口相连,控制595是否被选中,低电平有效。
然后介绍一下,如何焊接LED等的问题。
一种是长方体雾状的LED灯:焊接参考:/link?url=SXmoc9lSihpyBXd6qBQ0XsWZaoBV UykrQawWIJKRz4WmNMohW_Z1WrSQOGYdeIzNLNJdNcwueAAyzgiIE bPhQFBaMZJj-GwVZ79TZ1BVTQ7另一种是圆形灯:焊接参考:/view/fb02d823a8114431b90dd84d.html两种方式焊接都注意把灯的正极焊接到灯座上,灯座可以用圆形的排母或者普通的排针。
示例程序:#include "reg52.h"#include <intrins.h>#define uchar unsigned char#define uint unsigned intsbit stcp1=P3^6;sbit ds1=P3^5;sbit shcp1=P3^7;void delay(){int i,j;for(i=0;i<50;i++)for(j=0;j<1000;j++);}void QR0_5951(uchar num1){uchar j;for (j=0;j<8;j++){num1=num1<<1 ;ds1=CY;shcp1=1;//上升沿发生移位shcp1=0;}}void OUT_5951()//将移位寄存器内的数据锁存到输出寄存器并显示{stcp1=0;stcp1=1;//上升沿将数据送到输出锁存器stcp1=0;}void tuan1(){P1=0x00; //x全部选中P2=0xff; //z全部选中QR0_5951(0xfe); //y 高电平亮OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0xfd); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0xfb); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0xf7); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0xef); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0xdf); //yOUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0xbf); //yOUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x7f); //yOUT_5951();delay();P2=0x00;}void tuan2(){P1=0x00; //x全部选中P2=0xff; //z全部选中QR0_5951(0x01); //y 高电平亮OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x02); //yOUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x04); //yOUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x08); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x10); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x20); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x40); //y OUT_5951();delay();P2=0xff; //z全部选中QR0_5951(0x80); //yOUT_5951();// delay();P2=0x00;}void tuan3(){P1=0x00; //x全部选中P2=0xff; //z全部选中QR0_5951(0x80); //y 高电平亮OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x40); //yOUT_5951();delay();P2=0xff; //z全部选中QR0_5951(0x20); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x10); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x08); //y OUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x04); //yOUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x02); //yOUT_5951();delay();P2=0x00;P2=0xff; //z全部选中QR0_5951(0x01); //yOUT_5951();delay();P2=0x00;}void tuan4(){P1=0x00; //x全部选中QR0_5951(0xff); //y全部选中OUT_5951();P2=0x01; //zdelay();P2=0x00;P2=0x02; //zdelay();// P2=0x00;P2=0x04; //zdelay();// P2=0x00;P2=0x08; //zdelay();/// P2=0x00;P2=0x10; //zdelay();// P2=0x00;P2=0x20; //zdelay();// P2=0x00;P2=0x40; //zdelay();// P2=0x00;P2=0x80; //z// delay();// P2=0x00;}void tuan5(){P1=0x00; //x全部选中QR0_5951(0xff); //y全部选中OUT_5951();P2=0x80; //zdelay();// P2=0x00;P2=0x40; //zdelay();// P2=0x00;P2=0x20; //zdelay();// P2=0x00;P2=0x10; //zdelay();/// P2=0x00;P2=0x08; //zdelay();// P2=0x00;P2=0x04; //zdelay();// P2=0x00;P2=0x02; //zdelay();// P2=0x00;P2=0x01; //zdelay();// P2=0x00;}void main(){P1=0x00; //xwhile(1){// tuan1();tuan2();tuan3();tuan4();tuan5();}}。
74ls595(含C程序)
} } void SendOneLine() //写入数据到 595 { uchar i = 0; uchar inc; if(col<8) inc = 0; else inc = 1; for(i=0+inc;i<=7+inc;i++) //i<=2*要显示的字数-1
74LS595 外形图
______
QB--|1 16|--Vcc
QC--|2 15|--QA
QD--|3 14|--SI
QE--|4 13|--/G
QF--|5 12|--RCK
QG--|6 11|--SCK
QH--|7 10|--/SCLR
GND-|8
9|--QH'
|_____ |
74595 的数据端: QA--QH: 八位并行输出端,可以直接控制数码管的 8 个段。 QH': 级联输出端。我将它接下一个 595 的 SI 端。 SI: 串行数据输入端。
} } //********LED 显示数字,向 595 发送一个字节的数据,然后发送位选信号******* void wr7leds(void) { uchar i,wx; wx=0x01; //位选信号初始化 for(i=0;i<4;i++) //循环 4 次写 4 个数据 { wr595(LED_7SEG[i]); //传送显示数据 PORT_LED=~wx; //送位选信号 wx<<1; //位选信号左移,准备显示下一个数字 delay(50); //延时,(决定亮度和闪感) } } //**********主函数********** void mian() { while(1) { wr7leds();//向 74HC595 发送数据 } }
基于单片机的光立方设计含程序+原理图+实物图)
74HC595protues原理图和程序
74hc595;文件名:74hc595.c;功能:使用74HC595制作6位静态显示电路,在数码管上分别显示123456。
;硬件:见图8-4*/#include "pic.h"typedef unsigned char uchar;typedef unsigned int uint;__CONFIG(HS&WDTDIS&LVPDIS);//配置文件,设置为HS方式振荡,禁止看门狗,低压编程关闭#define Dat RB1 //定义串行数据输入端#define Clk R B0 //定义时钟端#define RCK RB2 //定义控制端uchar DispBuf[6]={1,2,3,4,5,6};const uchar DispTab[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x8 6,0x8E,0xFF};//定义定形码表void SendData(unsigned char SendDat) //传送一个字节的数据数据{ unsigned char i;for(i=0;i<8;i++){ if((SendDat&0x80)==0)Dat=0;elseDat=1;Clk=0;Clk=1;SendDat=SendDat<<1;}}void Disp(){ uchar c;uchar i;RCK=0; //存储寄存器输入禁止for(i=0;i<6;i++){ c=DispBuf[5-i]; //取出待显示字符,先送高位SendData(DispTab[c]); //送出字形码数据}RCK=1; //存储寄存器输入允许}void main(){ TRISB=0; //设置PORTB为输出Disp();for(;;);}。
单片机结合595芯片实现红绿灯程序实例
一、实验任务通过使用595芯片实现交通灯的效果。
一、电路原理图二、系统板上硬件连线(1.把“单片机系统”区域中的P1.0-P1.2端口连接到第一块“595芯片”中 ST_CP,SH_CP,DS上;要求:P1.0对应着DS,P1.1对应着ST_CP,P1.2对应着SH_CP;(2.把“单片机系统”区域中的P1.3-P1.5端口连接到第二块“595芯片”中 ST_CP,SH_CP,DS上;要求:P1.3对应着DS,P1.4对应着ST_CP,P1.5对应着SH_CP;(3.第一块“595芯片”上Q0-Q5端口连接到LED灯1,2,7,8,9,12号上;要求:Q0对应7号LED灯,Q1对应12号LED灯,Q2对应1号LED灯,Q3对应2号LED灯,Q4对应9号LED灯,Q5对应8号LED灯;(4.第二块“595芯片”上Q0-Q5端口连接到LED灯3,4,5,6,10,11号上;要求:Q0对应5号LED灯,Q1对应10号LED灯,Q2对应4号LED灯,Q3对应6号LED灯,Q4对应11号LED灯,Q5对应3号LED灯;三、实验内容设计通过单片机控制两块“595芯片”,从而控制12个LED灯;具体要求:东西方向南北方向红灯(10s)绿灯(10s)红灯(03s)黄灯(03s)绿灯(10s)红灯(10s)黄灯(03s)红灯(03s)不断循环。
五、实验框图六、C语言编程#include<reg52.h>unsigned char i;unsigned char t0=0,state=0;sbit spi_shcp0=P1^2;sbit spi_stcp0=P1^1;sbit spi_ds0=P1^0;sbit spi_shcp1=P1^5;sbit spi_stcp1=P1^4;sbit spi_ds1=P1^3;void delay_05ms(void){unsigned int i;for (i=0;i<250;i++);}void hc595send_data0(unsigned char date) {unsigned char i;spi_stcp0= 0;for(i=0;i<8;i++){spi_shcp0= 0;if((date&0x80)!=0)spi_ds0= 1;elsespi_ds0= 0;date <<= 1;spi_shcp0= 1;}spi_stcp0= 1;}void hc595send_data1(unsigned char date) {unsigned char i;spi_stcp1= 0;for(i=0;i<8;i++){spi_shcp1= 0;if((date&0x80)!=0)spi_ds1= 1;elsespi_ds1= 0;date <<= 1;spi_shcp1= 1;}spi_stcp1= 1;}void timer0() interrupt 1{static unsigned char nn;TH0=0x3c;TL0=0xb0;nn++;if(nn==20){nn=0;t0++;}}void main(){ unsigned int k;TMOD=0x01;TH0=0x3c;TL0=0xb0;TR0=1;ET0=1;EA=1;while(1){switch(state){case 0:hc595send_data1(0x21);if(t0==10) {state=1;t0=0;}break;case 1:for(k=0;k<6;k++){hc595send_data0(0x11);hc595send_data1(0x11);delay_05ms();hc595send_data0(0x01);hc595send_data1(0x01);if(t0==3) {state=2;t0=0;}break;}break;case 2:hc595send_data0(0x24);hc595send_data1(0x0c);if(t0==10) {state=3;t0=0;}break;case 3:for(k=0;k<6;k++){hc595send_data1(0x0a);delay_05ms();hc595send_data0(0x20);hc595send_data1(0x08);if(t0==3) {state=0;t0=0;}break;}}}}。
基于74hc595和74hc138的点阵显示
基于74hc595和74hc138的点阵显示基于74hc595和74hc138的16x40点阵显示 作者:廖基鑫 桂林电子科技大学 一、电路原理图 (1)输入输出口JP1为输入口,JP2为输出口(为串联下一块点阵),245为电平转换 (2)行控制端电路有2块3-8译码器组成4-16译码器。
将A,B,C,D,接入一个8位I/O 口,直接 对I/O 口赋值⑶行写入端电路、74HC595介绍。
74HC595是一款漏极开路输出的CMO够位寄存器,输出端口为可控的三态输出端,亦能串行输出控制下一级级联芯片。
10脚SCLR移位寄存器清零端直接接地,11脚SCK数据输入时钟线12脚RCK输出存储器锁存时钟线13脚OE输出使能低电平为输出有效14脚SI数据线串行输入数据,亦能串行输出数据到下一级级联芯片输入数据程序:1.向595写一个字节的数据void write_595(uchar DATA)// 向595 写一个字节的数据{ uchar i;for(i=0;i<8;i++){SI=(~DATA )&0x01;SCK=1;SCK=0;DATA=DATA>>1;}2.向多个595写一个字节的数据9脚SQH位串行数据输出管脚将多个595的数据由9脚传至下一个595,全部写入后在打开输出存储器锁存时钟线for(i=0;i<16;i++) // 字从下往上滚动出现k=1;for(j=i+1;j>0;j--) // 向多个595 写一个字节的数据{ write_595(display[7][k]); write_595(display[7][k-1]); write_595(display[6][k]); write_595(display[6][k-1]); write_595(display[5][k]); write_595(display[5][k-1]); write_595(display[4][k]); write_595(display[4][k-1]); k+=2;hang=16-j; // 为138 输入行控制数据RCK=1;RCK=0;}delay_ms(20);}3(595-RCK信号与138的输出使能E2信号为同一信号,故可以相连。
DIY点阵模块程序讲解—74HC595程序
23:
24: for ( i = 0; i < 8; i++ )
C:0x031F E4
CLR
A
C:0x0320 FE
MOV
R6,A
25: {
26:
PDATA_H = (bit)( Data&0x08);
C:0x0321 EF
MOV
A,R7
C:0x0322 A2E3 MOV
C,0xE0.3
C:0x0324 92A0 MOV
呵呵 ,我想这个总结留给大家自己来总总结,大家自己总结能学到更多东西,大家可以 自己把每一种方法都试一下,自己分析总结一下,由于时间方面比较紧,可能有不足之处, 欢迎大家指正,如果大家有更好的方法欢迎和大家一起分享,也好让我学习一下。 74HC595 发送数据时先发高位,则数据位和管脚位相对应 74HC595 发送数据时先发高位, 则数据位和管脚位相对应,低位在前是数据位和管脚位相反。 以下是三个程序发送低位在前的参考程序。 方法一: void Send_Hang ( uint8 Data ) {
{ PDATA_H = (bit)( Data&0x08);/*送一位数据,强制转换为位数据型,*/
PCLK_H = 0;
PCLK_H = 1;
Data<<=1;
}
} 我们可以看看汇编的结果是怎么样的,
19: void Send_Hang ( uint8 Data )
20: {
21:
22: uint8 i;
uint8 i; PDATA_H = (bit)( Data&0x01); PCLK_H = 0; PCLK_H = 1; Data>>=1; } 方法三: void Send_Hang ( uint8 Data ) { uint8 i; ACC = Data; CY = 0; for ( i = 8; i > 0; i-- ) { PDATA_H = ( ACC & 0x01 ); PCLK_H = 0; PCLK_H = 1; } }
595光立方资料
10{ int i, speed speed = 300; oe1=0x01; //测试oe移动是否正确 led=0xff;layer=0xff; for(i=0;i<8;i++) { oe=~oe1 ; delay(speed); oe1<<=1; } oe=0;led =0xff;layer1=0x01; //测试层移动是否正确 for(i=0;i<8;i++) { layer=layer1; delay(speed); layer1<<=1; } layer=0xff;oe=0;led1=0x0 1; //测试led数据段移动是否正确 for(i=0;i<8;i++) { led=led1; delay(speed); led1<<=1; } }void main(void) { uchar z; uchar i; timerinit(); while(1) { if(EA==0) { oe=~0x80; yi dongzi(20,t2); yidongzi(20,t3); yidongzi(20,t4); yidongzi(20,t5); yidongzi(20,t6); yidon gzi(20,t7);11yidongzi(20,t8); yidongzi(120,t9); yizi(t2); yizi(t3); yizi(t4); yizi(t5); yizi(t6); yizi( t7); yizi(t8); dot(); for(z=0;z<200;z++)kuang(); for(z=0;z<5;z++)testled(); // full(t1); } } }void time_int0() interrupt 1 { static uint i; oe=0;layer=0xff; PWM_Match++; //让PWM对比值自加 1 if(PWM_Match > PWM_MAX) PWM_Match = 0; //判断是否超出, if(PWM > PWM_Match) LED = 0; //如果PWM大于PWM对比值,则点亮LED } else { LED=0xff; } if(Breath_Count == Breath_Speed) { i++; Breath_Count = 0; if(Breath_Direction == 0) { PWM++; if(PWM > PWM_MAX) Breath_Direction = 1; } else { PWM--; if(PWM == 0) Breath_Direction = 0; } }12Breath_Count++; if(i==1000) {i=0;EA=0; } }#include <reg51.h>#define uchar unsigned char #define uint unsigned int sbit SH_CP=P2^0; sbit DS=P2^1; sbit ST_ CP=P2^2;uchar code tab[ ]= {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" ",0 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// " ",1 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" ",2 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x 00,//" ",3 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" ",4 0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,//" ",5 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" ",6 0x00,0x00,0x00,0x00,0x00,0x00 ,0x00,0x00,//" ",7 0x00,0x3E,0x41,0x41,0x41,0x41,0x3E,0x00,//"0",8 0x00,0x00,0x20,0x20,0x7F ,0x00,0x00,0x00,//"1",9 0x00,0x21,0x43,0x45,0x45,0x49,0x31,0x00,//"2",10 0x00,0x22,0x41,0x4 9,0x49,0x49,0x36,0x00,//"3",11 0x00,0x04,0x0C,0x14,0x24,0x7F,0x04,0x00,//"4",12 0x00,0x72, 0x51,0x51,0x51,0x53,0x4E,0x00,//"5",13 0x00,0x3E,0x6B,0x49,0x49,0x49,0x26,0x00,//"6",14 0 x00,0x40,0x41,0x42,0x4C,0x50,0x60,0x00,//"7",15 0x00,0x36,0x49,0x49,0x49,0x49,0x36,0x00,/ /"8",16 0x00,0x32,0x49,0x49,0x49,0x4B,0x3E,0x00,//"9",17 0x00,0x00,0x00,0x00,0x00,0x00,0x 00,0x00,//" ",0 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" ",10x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" ",2 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// " ",3 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" ",4 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" ",5 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" ",6 0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,0x00,//" ",7 };//顺向、逐列、阴码 MICROSOFT SANS SERIF 16x12 MATRIX-8X8-GREEN 右旋90度 X轴镜像void delay_ms(unsigned int ms) { uchar j; while(ms--) for(j=0;j<123;j++); }void WriteByte(uchar dat) { uchar k;for(k=0;k<8;k++) {dat=dat>>1; DS=CY;SH_CP=0; SH_CP=1; } }void main() {uchar num,temp,n,m; P1=0x00; while(1) {for(n=0;n<144;n++) //for(m=0;m<12;m++) //重复显示12次 {temp=0; //for(num=n;num<8+n;num++) if(temp==8) { temp=0; P1=0x00; } else {WriteByte(tab[num+72]);WriteByte(tab[num+64]);WriteByte(tab[num+56]);WriteByte(tab[num+48]);WriteByte(tab[num+40]);WriteByte(tab[num+32]);WriteByte(tab[num+24]);WriteByte(tab[num+16]);WriteByte(tab[num+8]);WriteByte(tab[num+0]);P1=temp; ST_CP=0; ST_CP=1; delay_ms(1); temp++;}}}}105.2.3 LED立体点阵驱动显示方案LED立体点阵是一种新萌发的具有3D效果的。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
10 11 12 f1 13 f2 14 15 16 17
C1
30pF
C2
30pF
x3 d1
C3
10uF
x1 f1
பைடு நூலகம்
X1
R10
CRYSTAL
x2 f2 e1
NET=b0 1k
d2
PECKAGE=res300th
/*595 发送一字节*/ /***********************************************************************/ void Set595(unsigned char xie) {
unsigned char i; unsigned int temp; temp=xie; for(i=0;i<8;i++) {
sbit CLK=P1^1; //74HC595 的 SH-CP(11 脚)
sbit STB=P1^2; //74HC595 的时钟和输出锁存(12 脚)
/**********************************************************************/
/*坐标数组*/
R9
50k
PECKAGE=res300th
U2
C1 11 C2 14
SH_CP DS
C3 12 ST_CP
C410 a0 13
MR OE
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q7'
15 1 2 3 4 5 6 7 9
74HC595 PECKAGE=SOP16
U3
C1 11 14
SH_CP DS
/**********************************************************************/
uchar code shu[8]={0,1,2,3,4,5,6,7};
//十进制数选
uchar code x1[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//595 数据
+5V
U1
d1 19 XTAL1
d2 18 XTAL2
e1
9 RST
+5V
29 30 31
PSEN ALE EA
C2 C1 C3
C4
220UF
1 2 3 4 5 6 7 +58V
P1.0/T2 P1.1/T2EX P1.2 P1.3 P1.4 P1.5 P1.6 P1.7
AT89C52
P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7
if(temp&0x01) {
DS=1; } else DS=0; temp=temp>>1; CLK=0; _nop_(); _nop_(); CLK=1; //移位上升沿有效? } } /**********************************************************************/
P2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15
P3.0/RXD P3.1/TXD P3.2/INT0 P3.3/INT1
P3.4/T0 P3.5/T1 P3.6/WR P3.7/RD
39 38 37 36 35 34 33 32
C3 12 ST_CP
C4 10 a0 13
MR OE
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q7'
15 1 2 3 4 5 6 7 9
74HC595 PECKAGE=SOP16
C1 11 14
C312
U4
SH_CP DS
ST_CP
C410 a0 13
MR OE
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q7'
15 1 2 3 4 5 6 7 9
74HC595 PECKAGE=SOP16
U5
C1 11 14
SH_CP DS
C3 12 ST_CP
C4 10 a0 13
MR OE
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q7'
15 1 2 3 4 5 6 7 9
74HC595 PECKAGE=SOP16
备注:上面的 3 个按键可以只要 1 个,另外 2 个是我设计的外部中断,你可以不用它;同时 我自己有开发板,所以我没有设计程序下载电路,全以最节省的方案为前提,你只要把单片 机在开发板上下载好程序,再插到光立方上就好了。同时画电路时每个芯片的电源引脚隐藏 了,(单片机是 20 接负,40 接正;595 是 8 接负,16 接正;7404 是 7 接负,14 接正。),还 有注意电解电容的极性。关于你接电源的问题是你自己的事,我是在板子上面安装了一个 USB 的接口供电。
MR OE
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q7'
15 1 2 3 4 5 6 7 9
74HC595 PECKAGE=SOP16
U8
C1 11 14
SH_CP DS
C3 12 ST_CP
C4 10
a0
13
MR OE
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q7'
15 1 2 3 4 5 6 7 9
下面我会给你一段程序,我的的时间有点忙,没有那么多时间来写花样。
#include<reg52.h>
#include <intrins.h>
//空语句调用头文件
#include"zimo.h"
#define uchar unsigned char
#define uint unsigned int
/**********************************************************************/
U6
C1 11 14
SH_CP DS
C3 12 ST_CP
C4 10 a0 13
MR OE
Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q7'
15 1 2 3 4 5 6 7 9
74HC595 PECKAGE=SOP16
C111 14
U7
SH_CP DS
C3 12 ST_CP
C4 10 a0 13
uchar code y1[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//595 使能
uchar code z1[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};//层扫描
/************************************************************************/
/*亮度调节延时*/
/************************************************************************/
void delay(unsigned int i)
{
unsigned int j;
for(;i>0;i--)
{
for(j=5;j>0;j--);
}
}
/**********************************************************************/
/*ms 延时*/
/**********************************************************************/
/**********************************************************************/ void Set595_1(unsigned char xie,unsigned char xie1) {
unsigned char i; for(i=0;i<8;i++) {
/**********************************************************************/
void dis595(void)
{
STB=0;
_nop_();
_nop_();
STB=1;
//串行输出上升沿有效
}
/**********************************************************************/
/*方框缩放*/ /**********************************************************************/
sbit DS=P1^0;
/**********************************************************************/
/**********************************************************************/
void delayms(uchar xms)
{
uchar i,j;
for(i=0;i<xms;i++)