#include <reg51.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <intrins.h> #include <absacc.h> #include <string.h> sbit SB0 = P2^1;//MBI5169LE/MOD sbit LE = P2^0;//MBI5169OE sbit ST = P2^4;//NO USE sbit LN = P2^2;//LS138 -E2 unsigned char i; unsigned char ledbuf[32]={0x55,0x55,0x55,0x55,0x44,0x44,0x33,0x33,0x22,0x22,0x11,0x11,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x88,0x88,0x77,0x77,0x66,0x66,0x55,0x44,0x55,0x55}; void send_char_com(unsigned char ch[],unsigned char chi) { SBUF=ch[chi]; while(TI==0); TI=0;}
void delay15(unsigned int vv) { unsigned int delayi; for(delayi=0;delayi<vv;delayi++);} void init(void) { SCON= 0x00; ES =0; EA =0; SB0=0; LE=1; ST=0; LN=0; TI=0;} void main(void) { delay15(50000); init(); while(1) { for(i=0;i<16;i++) { SB0=0; LE=1; send_char_com(ledbuf,2*i); send_char_com(ledbuf,2*i+1); SB0=1; _nop_() ; SB0=0; LE=0; P1=i; delay15(60);//quan xian time } } |