matrix.c  



Example to drive 5 x 7 Matrix LED

/************************************************
 *                                              *
 *      COPYRIGHT (c) Blitzlogic Sdn. Bhd.      *
 *      Author : Abraham Wong 21/1/2000         *
 *                                              *
 *      example of driving 5 x 7 Matrix LEDs    *
 *                                              *
 ************************************************/

  #include <16c84.h> 

  #USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */

  #FUSES XT,NOWDT,NOPROTECT,NOPUT 
  /* Use XT mode, No Watch Dog, No Code Protect, No Power-up Timer */

  #byte port_b=6 /* define the location of register port_b */
  #byte port_a=5 /* define the location of register port_b */

  char const pat[5]={0x3f,0x02,0x04,0x02,0x3f}; 


  main(){
    char cnt, col; 
   
    set_tris_b(0); /* set port_b as outputs */
    set_tris_a(0); /* set port_a as output */
    
    port_b = 0; /* ZERO port_a & port_b */
    port_a = 0;

    for( ;; )
     {
        col = 1;
      for(cnt = 0;cnt < 5;cnt++)
       {
        port_b = pat[cnt];
          port_a = col;
           
            delay_ms(1);
           
             col<<=1;
              }
          }
      }



Navigation Bar

tech_support@blitzlogic.com