#include "C:\Program Files\PICC\Examples\0-999_butonla_sayıcı\0-999_say.h"
#fuses XT,NOPROTECT,NOWDT,NOWRT,NOPUT,NODEBUG,NOBROWNOUT,NOLVP,NOCPD
#use delay(clock=4000000)
#define buton pin_c0
#use fast_io(b)
#use fast_io(c)
const int dijit[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
int16 birler=0,onlar=0,sayi=0,yuzler=0,kalan;
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_CCP1(CCP_OFF);
setup_CCP2(CCP_OFF);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
set_tris_c(0x01);
set_tris_b(0x00);
output_b(0x00);
for(;
{
birler=sayi%10;
kalan=sayi/10;
onlar=kalan%10;
yuzler=sayi/100;
output_high(pin_c3);
output_low(pin_c1);
output_b(dijit[birler]);
delay_ms(5);
output_high(pin_c1);
output_low(pin_c2);
output_b(dijit[onlar]);
delay_ms(5);
output_high(pin_c2);
output_low(pin_c3);
output_b(dijit[yuzler]);
delay_ms(5);
if(input(buton))
{
sayi++;
if(sayi==1000)
sayi=0;
birler=sayi%10;
kalan=sayi/10;
onlar=kalan%10;
yuzler=sayi/100;
while(input(buton))
{
output_high(pin_c3);
output_low(pin_c1);
output_b(dijit[birler]);
delay_ms(5);
output_high(pin_c1);
output_low(pin_c2);
output_b(dijit[onlar]);
delay_ms(5);
output_high(pin_c2);
output_low(pin_c3);
output_b(dijit[yuzler]);
delay_ms(5);
output_high(pin_c3);
}
}
}
}