| |
Example to drive two 7-Segment LEDs
/****************************************
*
* COPYRIGHT (c) Blitzlogic Sdn. Bhd.
* Author : Abraham Wong 21/1/2000
*
* example of using FOR loop to drive
* two 7-Segment LEDs
****************************************/
#include <16c84.h>
#USE DELAY( CLOCK=4000000 ) /* Using a 4 Mhz clock */
#FUSES XT,NOWDT,NOPROTECT,NOPUT
/* Use XT mode, No Watch Dog, No Code Protect, No Power-up Timer */
#byte port_b=6 /* define the location of register port_b */
#byte port_a=5 /* define the location of register port_b */
byte CONST LED_MAP[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
main(){
byte cnt, right,num ;
set_tris_b(0); /* set port_b as outputs */
set_tris_a(0); /* set port_a as output */
port_b = 0; /* ZERO port_a & port_b */
port_a = 0;
for( ;; ){
for (right=1;right<3;right++){
port_a = right;
for (cnt=0;cnt<10;cnt++){
port_b = LED_MAP[cnt];
DELAY_MS(1000); /* one second delay */
}
}
}
}
|