- #include <STC15W.h>
- #include <intrins.h>
- sbit DIN_4094_1 = P6^5; //data
- sbit ST_4094_1 = P6^7; //str
- sbit CLK_4094 = P4^3; //SLK
- unsigned char code zheng[8]={0x08,0x0c,0x04,0x06,0x02,0x03,0x01,0x09}; //逆时钟旋转相序表
- unsigned char code fan[8]={0x09,0x01,0x03,0x02,0x06,0x04,0x0c,0x08}; //正时钟旋转相序表
- void TransByteTo4094_ElecExpValve1(unsigned char dat16_09);
- void delay_us(unsigned char i)
- {
- unsigned char j;
- for(i; i>0;i--)
- for(j = 200;j>0;j--);
- }
- void delay(unsigned int o)
- {
- while(--o);
- }
- void main()
- {
- unsigned char n,k;
- unsigned char m;
- unsigned int time = 0;
- while(1)
- {
- for(time = 0; time < 50;time++)
- {
- for(k = 0;k < 8; k++)
- {
- m = zheng[k];
- TransByteTo4094_ElecExpValve1(m);
- delay(500);
-
- }
- }
- for(time = 0; time < 50;time++)
- {
- for(n = 0;n < 8; n++)
- {
- m = fan[n];
- TransByteTo4094_ElecExpValve1(m);
- delay(500);
- }
- }
- }
- }
- void TransByteTo4094_ElecExpValve1(unsigned char dat16_09)
- {
- unsigned char j;
- unsigned char i,tt;
- CLK_4094 = 1;
- ST_4094_1 = 1;
-
- tt = dat16_09;
- for(i = 0;i<8;i++)
- {
- j = tt &(0x01);
- if(j == 1)
- { DIN_4094_1 = 0; }
- else
- { DIN_4094_1 = 1; }
- CLK_4094 = 1;
- delay_us(10);
- CLK_4094 = 0;
- delay_us(10);
- tt = tt>>1;
- }
- ST_4094_1 = 1;
- delay_us(10);
- ST_4094_1 = 0;
- delay_us(10);
- CLK_4094 = 1;
- ST_4094_1 = 1;
- DIN_4094_1 = 1;
- }
复制代码 |