led_spj.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 : SPJ 8051 C - DEMO             *
 *                                              *
 ************************************************/

 #include < sfr31.h >  /* Include 8031 / 8051 SFR definition header file */

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

 void main( )
      {
       unsigned char j ;

    while( 1 )
     {                         /* Loop forever */
      for (j = 0 ; j < 8 ; j ++ )
         {   /* Blink LED 0,1,2,3,4,5,6,7 */
            
           P1 = num[j] ;                /* Output to LED Port */
           delay_ms(500) ;              /* Delay of 500 ms */
           }
      }
 }
  

Navigation Bar

tech_support@blitzlogic.com