Guest User

Untitled

a guest
Apr 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. char a;
  2. char i;
  3.  
  4.  
  5. void main ()
  6. {
  7.  
  8. for (i=0; i<=3; i++)
  9.     {
  10.     PORTC.i = 0;
  11.     PORTB.i = 0;
  12.     test_lines;
  13.     }
  14. }
  15.  
  16.  
  17. void test_lines ()
  18.  
  19. {
  20. for (a=4; a<=7; a++)
  21.     {
  22.     if PORTC.a=1 PORTB.a=debounce(a)
  23.     }
  24. }
  25.  
  26. void debounce (char a)
  27.  
  28. {
  29. delay(5);
  30. if PORTC.a=1 return 1;
  31. return 0;
  32. }
  33.  
  34. void delay(char millisec)
  35. /* delays a multiple of 1 millisecond at 4 MHz */
  36. {
  37. OPTION = 2; /* prescaler divide by 8 */
  38. do {
  39. TMR0 = 0;
  40. clrwdt(); /* only if necessary */
  41. while (TMR0 < 125) /* 125 * 8 = 1000 */
  42. ;
  43. } while (-- millisec > 0);
  44. }
Add Comment
Please, Sign In to add comment