SHARE
TWEET

Button.c

a guest Jun 16th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top