7SEG_SPJ.C  



Example to drive two 7-Segment LEDs

/*****************************************   
 *  COPYRIGHT (c) BLITZLOGIC Sdn Bhd     *
 *  - by A. Wong 1/2/2000		      *
 *                                       *
 *  example of using FOR loop to drive   *
 *  two 7-Segment LEDs  		      *
 *                                       *
 *  Compiler : IDE51 C Compiler - SPJ    *
 *                                       *
  ****************************************/

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

 unsigned char num[10] = { 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f };
void main( ){ unsigned char cnt, right; P1 = 0; // initialize all P1 outputs to be zero
P3 = 0; while(1) { for( right=1; right<3; right++ ) { P3 = right; for( cnt=0; cnt<10; cnt++ ) { P1 = num[cnt]; delay_ms(500); // half second delay // Assuming 12Mhz Crystalsp; } } } }

Navigation Bar

tech_support@blitzlogic.com