Single chip dual color dot matrix display specific graphics

Publisher:鑫森淼焱Latest update time:2018-05-12 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/*-----------------------------------------------  

  Name: Two-color dot matrix  

  Forum: www.doflye.net  

  Written by: shifang  

  Modification: None  

  Content: Using hc595 to drive two-color dot matrix   

------------------------------------------------*/  

#include //Include the header file. Generally, no modification is required. The header file contains the definition of special function registers.  

#include   

  

  

//unsigned char  segout[8]={0,1,2,3,4,5,6,7}; //8列  

unsigned char  segout[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; //8列  

unsigned char code tab[]={  

                        0x08,0x1C,0x3E,0x7F,0x1C,0x1C,0x1C,0x1C,  

                        };  

  

  

/*------------------------------------------------  

                Hardware Port Definition  

------------------------------------------------*/  

sbit LATCH = P1^0;   

sbit SRCLK= P1^1;  

sbit SER = P1^2;  

  

  

  

  

sbit LATCH_B = P2^2;  

sbit SRCLK_B= P2^1;  

sbit SER_B= P2^0;  

  

  

/*------------------------------------------------  

 uS delay function, with input parameter unsigned char t, no return value  

 unsigned char is used to define an unsigned character variable, whose value range is  

 0~255 Here we use a 12M crystal oscillator. Please use assembly for accurate delay. Approximate delay  

 The length is as follows: T=tx2+5 uS   

------------------------------------------------*/  

void DelayUs2x(unsigned char t)  

{     

 while(--t);  

}  

/*------------------------------------------------  

 mS delay function, with input parameter unsigned char t, no return value  

 unsigned char is used to define an unsigned character variable, whose value range is  

 0~255 Here we use a 12M crystal oscillator. Please use assembly code for accurate delay.  

------------------------------------------------*/  

void DelayMs(unsigned char t)  

{  

       

 while(t--)  

 {  

     //About 1mS delay  

     DelayUs2x(245);  

DelayUs2x(245);  

 }  

}  

/*------------------------------------------------  

                Send Bytes Program  

------------------------------------------------*/  

void SendByte(unsigned char dat)  

{      

  unsigned char i;   

          

   for(i=0;i<8;i++)  

        {  

         SRCLK=0;  

         SER=that&0x80;  

         dat<<=1;  

         SRCLK=1;  

         }  

           

}  

/*------------------------------------------------  

                Send double byte program  

     595 cascade, n 595, need to send n bytes and then latch  

------------------------------------------------*/  

void Send2Byte(unsigned char dat1,unsigned char dat2)  

{      

   SendByte(dat1);  

   SendByte(dat2);        

}  

/*------------------------------------------------  

                   595 Latch Program  

 After 595 cascade sends data, latch is valid  

------------------------------------------------*/  

void Out595(void)  

{  

        LATCH=1;  

        _nop_();  

        LATCH=0;  

}  

  

  

/*------------------------------------------------  

                Send Bitcode Bytes Program  

               Use another separate 595  

------------------------------------------------*/  

void SendSeg(unsigned char dat)  

{      

unsigned char i;   

          

   for(i=0;i<8;i++) //send bytes  

        {  

         SRCLK_B=0;  

         SER_B=dat&0x80;  

         dat<<=1;  

         SRCLK_B=1;  

         }  

      LATCH_B=1; //Latch  

      _nop_();  

      LATCH_B=0;  

           

           

}  

/*------------------------------------------------  

                   Main Program  

------------------------------------------------*/  

void main()  

{  

unsigned char i,j,k;  

while(1)  

{  

  

  

              for(i=0;i<8;i++) //8 columns display  

                  {  

                     SendSeg(segout[i]);  

  

Send2Byte(~tab[i],0xff); //Display arrow graphics at fixed position  

Out595();  

                     DelayMs(1);  

  

Send2Byte(0xff,0xff);//delay(10); //Prevent ghosting  

Out595();  

                  }  

            

        }  

}  


Reference address:Single chip dual color dot matrix display specific graphics

Previous article:MCU DS18b20 Temperature detection LCD display
Next article:Single chip dual color dot matrix display 1 color

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号