Advertisement
Guest User

Ifpin

a guest
Apr 28th, 2013
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. char IfPinLow (const uint16_t MYPORT, const uint8_t MYPIN )
  2. {
  3.    
  4.     uint8_t lowcount = 0;
  5.     for(uint8_t y=0; y<2; y++)
  6.     {
  7.         for(uint8_t i=0; i<51; i++)
  8.         {
  9.             if((MYPORT & MYPIN) == 0) lowcount++;
  10.             _delay_ms(1);
  11.         }
  12.        
  13.     }
  14.    
  15.     if(lowcount >= 75) return 1;
  16.     return 0;
  17. }
  18.  
  19. char IfPinHigh (const uint16_t MYPORT, const uint8_t MYPIN )
  20. {
  21.     uint8_t highcount = 0;
  22.     for(uint8_t y=0; y<2; y++)
  23.     {
  24.         for(uint8_t i=0; i<51; i++)
  25.         {
  26.             if(MYPORT & MYPIN) highcount++;
  27.             _delay_ms(1);
  28.         }
  29.        
  30.     }
  31.    
  32.     if(highcount >= 75) return 1;
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement