Professional Documents
Culture Documents
Codigo Contador en Xc8
Codigo Contador en Xc8
h>
#define _XTAL_FREQ 4000000
#pragma config BOR4V = BOR40V // Brown-out Reset Selection bit (Brown-out Reset
set to 4.0V)
#pragma config WRT = OFF // Flash Program Memory Self Write Enable bits
(Write protection off)
int cuenta;
int
display[10]={0b1000000,0b1111001,0b0100100,0b0110000,0b0011001,0b0010010,0b0000010,
0b1111000,0b0000000,0b0010000};
void main(void)
{
ANSEL=0;
ANSELH=0;
TRISAbits.TRISA0=1;
TRISB=0;
while(1)
{
if(PORTAbits.RA0==1)
{
PORTB=display[cuenta];
}
else
{
__delay_ms(300);
cuenta++;
if(cuenta>9)
{
cuenta=0;
}
}
}
return;
}