Kód: Vybrat vše
unsigned cnt;
unsigned butt;
unsigned butt_1;
void InitTimer0(){
OPTION_REG = 0x86;
TMR0 = 100;
INTCON = 0xA0;
}
void Interrupt(){
if (TMR0IF_bit){
cnt++;
TMR0IF_bit = 0;
TMR0 = 100;
}
}
void main() {
InitTimer0();
TRISA1_bit = 00;
TRISA0_bit = 00;
TRISB = 0xFF;
RA0_bit = 00;
cnt = 0;
butt= 0;
butt_1= 0;
do {
if (cnt >= 300) {
butt = 0;
butt_1 = 0;
cnt = 0;
}
if (RB1_bit == 01)
{
delay_ms(300);
if (RB1_bit == 01)
{
RA0_bit = 01;
}
butt_1++;
if (butt_1 >= 1)
{
butt++;
if(butt == 5)
{
RA1_bit = 01;
butt = 0;
}
}
}
}while(1);
}
![Smile :)](./images/smilies/icon_smile.gif)