| |
Example to drive two 7-Segment LEDs
/********************************************
* COPYRIGHT (c) Blitzlogic Sdn. Bhd. *
* *
* Author : Abraham Wong 1/2/2000 *
* *
* 7 SEG LED using Keil C *
* on 89C2051 Target board *
* Compiler : KEIL C - 2K EVAL *
* *
*******************************************/
#include < at89C2051.h > /* Include 89C2051 header file */
char num[ ] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void wait (void) /* wait function */
{ ; }
void main( void ){
unsigned char cnt, right;
unsigned int i;
P1 = 0; /* ZERO port P1 & port P3 */
P3 = 0;
for( ;; ){
for (right=0;right<3;right++)
{
P3 = right;
for (cnt=0;cnt<10;cnt++)
{
P1 = num[cnt];
for (i = 0; i < 10000; i++)
{
wait(); /* delay for half second */
}
}
}
}
}
|