led_89.c  



Example to drive 8 LEDS

/************************************************
 *                                              *
 *     COPYRIGHT (c) Blitzlogic Sdn. Bhd.       *
 *     Author : Abraham Wong 21/1/2000          *
 *                                              *
 *     example of using WHILE loop construct    *
 *     to drive 8 LEDS connected to port B      *
 *                                              *
 *     Compiler : KEIL C - 2K EVAL              *
 *                                              *
 ************************************************/

  #include < at892051.h > /* Include 89C2051 header file */ 
  
  char const num[  ] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; 

   void wait (void)
         { ; /* wait function */ 
            } 

   void main( void )
        {
         unsigned int i;
         unsigned char j; 

         P1 = 0; /* initialize ZERO to P1 */

          while(1){

          for(  j = 0; j < 8; j++  )
            {
               P1 = num[   j  ];
            
             for (  i = 0; i < 10000; i++   )
               {
                wait();  /* delay for half second */ 
                  }
              }
          }
      }
  

Navigation Bar

tech_support@blitzlogic.com