Advertisement
Einstein_R

Untitled

Jul 4th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <util/delay.h>
  3. #include <avr/interrupt.h>
  4. #include <stdbool.h>
  5. #include <string.h>
  6.  
  7. bool debButton(char *pin[], int x) // <---- CZY TU JEST DOBRZE PRZEKAZANE
  8. {
  9.  
  10.     _delay_ms(20);
  11.     if(bit_is_clear(*pin, x)) // <---- TUTAJ DZIAŁA
  12.     {
  13.     PORTB &= ~(1 << PINB3);
  14.         while ((bit_is_clear(*pin, x)))  // <---- TU JUZ NIE DZIAŁA
  15.         {
  16.  
  17.         }
  18.  
  19.         PORTB &= ~(1 << PINB3);
  20.         return true;
  21.     }
  22.     else
  23.     {
  24.         PORTB &= ~(1 << PINB3);
  25.         return false;
  26.     }
  27. }
  28.  
  29. void main(void)
  30. {
  31.  
  32. DDRB |= 1 << PINB0;
  33. DDRB &= ~(1 << PINB1);
  34. DDRB |= 1 << PINB2;
  35. DDRB |= 1 << PINB3;
  36.  
  37. PORTB |= 1 << PINB1;
  38. PORTB |= 1 << PINB3;
  39.  
  40. //bool redLed =0;
  41.  
  42.     while(1)
  43.     {
  44.         if(bit_is_clear(PINB,1))
  45.         {
  46.  
  47.             PORTB |= 1 << PINB0;
  48.             if(debButton("PINB",1))  // <---- TU JEST WYWOLANA TA CALA FUNKCJA
  49.             {
  50.                 PORTB ^= 1 << PINB2;
  51.             }
  52.             else
  53.             {
  54.  
  55.             }
  56.         }
  57.         else
  58.         {
  59.             PORTB &= ~(1 << PINB0);
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement