#include <avr/io.h>

//funkcia pre kratke pipanie
void pip(void)

{
unsigned int pom;
pom = 0;
   PORTB = PORTB | 0b00100000;       //zapnutie bzuciaka       
   TCCR1A = 0b00000000;              // T/C1 in timer mode
   TCCR1B = 0b00000101;              // prescale ck
   TCNT1 = 57722;                  // start value of T/C1 Low+High bytes
   TIFR1 = 0x01;                    //(1<<TOV1);   if a 1 is written to a TOV1 bit
                                    //             - the TOV1 bit will be cleared


 while (pom<8000){
 	pom++;

      if ( (TIFR1 & 0x01) == 0x01)   // If the overflow flag is set
      {
	  	pom++;
        PORTB = PORTB ^ 0b00100000;  // Toggle the 
        TCNT1 = 57722;                  // start value of T/C1 Low+High bytes
        TIFR1 = 0x01;                // Clear the overflow flag
       }
      else
        asm("nop"); 
	}


                      
}

//funkcia pre dlhe pipanie
void pip2(void)

{
unsigned int pom;
pom = 0;
   PORTB = PORTB | 0b00100000;		//zapnutie byuciaka	              
   TCCR1A = 0b00000000;              // T/C1 in timer mode
   TCCR1B = 0b00000101;              // prescale ck
   TCNT1 = 49910;
   TIFR1 = 0x01;                    //(1<<TOV1);   if a 1 is written to a TOV1 bit
                                    //             - the TOV1 bit will be cleared


 while (pom<60000){
 	pom++;

      if ( (TIFR1 & 0x01) == 0x01)   // If the overflow flag is set
      {
	  	pom++;
        PORTB = PORTB ^ 0b00100000;  // Toggle the 
        TCNT1 = 49910;
		TIFR1 = 0x01;                // Clear the overflow flag
       }
      else
        asm("nop"); 
	}


                  
}

