7SEG_90.C  


Example to drive two 7 Segment LEDs

/**************************************
 *                                    *
 * COPYRIGHT (c) Blitzlogic Sdn. Bhd. *
 * Author : Abraham Wong 1/2/2000     *
 *                                    *
 * 7 SEG LED using C - on ATMEL       *
 * AVR 90C2313 Target board           *	
 * Compiler : IMAGECRAFT AVR C        *
 *                                    *	
 **************************************/

#include < io2313.h >    /* Include for 90C2313 header file */ 
#include < macros.h >

char num[ ] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; 
              /* array data for 7-Segment Code for 0,1,2,....,9  */

void wait( ){  ;  }


void main(){

       unsigned char cnt, right;
       unsigned int i; 

        PORTB = 0; /* ZERO port P1 & port P3 */
        PORTD = 0;

    for( ;; )
      {
       for (right=0;right<3;right++){
        PORTD = right;
         for (cnt=0;cnt<10;cnt++)
           {
            PORTB = num[cnt];
              for (i = 0; i < 10000; i++)
                { 
                 wait();  /* delay for half second */ 
                   }
            }
        } 
    }
}


Navigation Bar
tech_support@blitzlogic.com