Advertisement
Guest User

Button.c

a guest
Jun 16th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. /*Button*/
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4.  
  5. #define F_CPU 16000000UL
  6.  
  7. int main(void)
  8. {
  9.     DDRD &= ~_BV(DDD2); //Set as input
  10.     DDRB |= _BV(DDB5); // set as output
  11.     PORTB= 0x00;
  12.  
  13.     while(1)
  14.     {
  15.         if(bit_is_set(PIND,PIND2))
  16.         {
  17.             PORTB|= _BV(PORTB5); // to set buzzer
  18.  
  19.         }
  20.         else
  21.         {
  22.             PORTB &= ~_BV(PORTB5);
  23.         }
  24.     }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement