#include <16f887.h>
#use delay(clock=4000000)
#fuses wdt, put, brownout, nomclr, intrc_io,protect
#byte porta = 0x05 //Definicion de variables del pic
#byte portb = 0x06
#byte portc = 0x07
#byte portd = 0x08
short bandera;
int contador;
int const valor []={6, 91, 79, 102, 109, 125, 7, 127, 111}; //Valores del 1 al 9 en el display 7 segmentos
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#zero_ram //Borrado de la memoria ram
void main() //Rutina principal
{
set_tris_b(0b00000001);
set_tris_d(0b00000000);
setup_oscillator(osc_4mhz);
while(true) //Rutina general
{
if(input(pin_b0) && !bandera)
{
bandera =1;
contador += 1;
if(contador == 10)
{
contador = 1;
}
portd = valor[contador];
}
else if(!input(pin_b0) && bandera)
{
bandera = 0;
}
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////