#include <reg51.h> #include <intrins.h>
#define uchar unsigned char sbit SB0 = P2^1;//MBI5169 LE/MOD sbit LE = P2^0;//MBI5169 OE sbit ST = P2^4;//NO USE sbit LN = P2^2;//LS138 -E2 sbit SCLK_595 = P3^1;// P2^3;//MBI5169 CLK sbit SDATA_595 = P3^0;// P2^7;//MBI5169 SDI sbit p26=P2^6; sbit p27=P2^5; unsigned char i,j;
unsigned char ledbuf[16] ={0x01,0x01,0x01,0x01,0x01,0xff,0x01,0x02,0x02,0x02,0x04,0x04,0x08,0x10,0x80,0x00}; unsigned char ledbuf1[16]={0x00,0x00,0x00,0x00,0x04,0xfe,0x00,0x80,0x80,0x40,0x40,0x20,0x10,0x0e,0x04,0x00};
void WR_595(uchar temp1) { uchar j ; for (j=0 ;j<8 ;j++) { SCLK_595=0 ;//加上的,要删去 temp1=temp1<<1 ; SDATA_595=CY ; //SCLK_595=0 ; //上升沿发生移位 _nop_() ; _nop_() ; _nop_() ; SCLK_595=1 ; _nop_() ; _nop_() ; } SCLK_595=0; } void delay15(unsigned int vv) { unsigned int delayi; for(delayi=0;delayi<vv;delayi++); } void init(void) { SB0=0; LE=0; ST=0; LN=0; TI=0; p26=0; p27=0; } void main(void) { // delay15(500);
init(); while(1) { for(i=0;i<16;i++) { LE=1; SB0=0; WR_595(ledbuf); //WR_595(ledbuf1); SB0=1; SB0=0; LE=0;
LE=1; SB0=0; // WR_595(ledbuf); WR_595(ledbuf1); SB0=1; SB0=0; LE=0; P1=i; /* WR_595(ledbuf1);
WR_595(ledbuf); WR_595(ledbuf1); WR_595(ledbuf); WR_595(ledbuf1); WR_595(ledbuf); WR_595(ledbuf1); WR_595(ledbuf); WR_595(ledbuf1); WR_595(ledbuf); WR_595(ledbuf1); WR_595(ledbuf); WR_595(ledbuf1); SB0=1; SB0=0; LE=0; P1=i; _nop_() ;*/ //delay15(2);//quan xian time } } } |