標(biāo)題: 單片機(jī)LED平面旋轉(zhuǎn)程序與原理圖 [打印本頁(yè)]

作者: hhhhhhjjjjjjjjj    時(shí)間: 2020-12-5 12:57
標(biāo)題: 單片機(jī)LED平面旋轉(zhuǎn)程序與原理圖
電路原理圖如下:



單片機(jī)源程序如下:
bit BIT_timeout=0;
void int0() interrupt 0        //使用外部中斷0
{
        BIT_timeout=1; //起點(diǎn)標(biāo)志位        
}


/*****************************************/
void Shift_data(unsigned char temp)          /*發(fā)送數(shù)據(jù)*/
{
        unsigned  char k;
        for(k=0;k<8;k++)//一個(gè)字節(jié)8位 發(fā)送給595
   {
           DATA_595=(bit)(temp&0x01);//通過(guò)IO口送一個(gè)位給 595
       temp=temp>>1;  //字節(jié)移位 準(zhǔn)備送下一位
           CLK_595=1;
           CLK_595=0;
   }
}

/*********延時(shí)子程序**********/
unsigned char  DelayUs(unsigned char N)
{
        unsigned char x ;
        for(x=0;x<=N;x++)
        {
                if(BIT_timeout)
                        return 1;
        }
        return 0;
}


unsigned int i=0,j=0;
unsigned char Data_L=0xff;
unsigned char Data_H=0xff;
unsigned char time_delay=0;
unsigned char k;

#define ucNumRows 176 //定義一周顯示字個(gè)數(shù)

void main_loop(void)
{
        
        
        if(BIT_timeout)        //起點(diǎn)判斷
         {                        
                BIT_timeout=0; //清零
                j++;
                if(j>(uiFontNumber-ucNumRows))
                        j = 0;
               
    for(i=j;i<(ucNumRows+j);i++)  //立體顯示176列 數(shù)據(jù)   176/16=11個(gè)字
    {   
                        Data_L=IapReadByte(i*2+2);        //緩沖數(shù)據(jù)低位
                        Data_H=IapReadByte(i*2+3);//緩沖數(shù)據(jù)高位        
                        Shift_data(Data_L);        //送數(shù)據(jù)低位顯示
                        Shift_data(Data_H);//送數(shù)據(jù)高位顯示        
                        CLK_595=1;
                        CLK_595=0;               
                        OE_595=0;
                        
                        if(DelayUs(35))//延時(shí)值 可以改變字體的寬度  值越大 字體越寬
                        {
                                OE_595=1;        
                                return;
                        }
                        OE_595=1;                                                        
                }   
        }
}


void main(void)
{
  init();        
        while(1)
        {
                main_loop();
        }
}

全部資料51hei下載地址:
上位機(jī)改字軟件.7z (177.86 KB, 下載次數(shù): 7)
平面旋轉(zhuǎn)程序(STC11L02E).zip (265.7 KB, 下載次數(shù): 7)





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1