单片机8*8点阵仿真和代码
- #include<reg52.h>
- sbit SH_CP=P2^0;
- sbit DS=P2^1;
- sbit ST_CP=P2^2;
- unsigned char code display[]={
- 0x04,0xFE,0x81,0xBE,0xAA,0xAA,0xBE,0x80,/*"未命名文件",0*/
- };
- void delay(unsigned int n)
- {
- unsigned int x,y;
- for(x=n;x>0;x--)
- for(y=120;y>0;y--);
- }
- void hc595_senddat(unsigned char dat)
- {
- unsigned char i;
- for(i=0;i<8;i++)
- {
- DS=dat&0x80;
- SH_CP=1;
- SH_CP=0;
- dat<<=1;
- }
- }
- main()
- {
- unsigned char i;
- SH_CP=0;
- ST_CP=0;
- while(1)
- {
- for(i=0;i<8;i++)
- {
- hc595_senddat(display[i]);
- P3=i;
- ST_CP=1;
- ST_CP=0;
- delay(5);
- }
- }
- }
复制代码
所有资料51hei提供下载:
8x8.rar
(36.66 KB, 下载次数: 47)
|