Advertisement
Guest User

Untitled

a guest
Sep 8th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <avr/io.h>
  2.  
  3. int main(){
  4. int pressed=0;
  5. int data=0b10101010;
  6. DDRB |=1 << PINB0;
  7. DDRB &=~(1<< PINB1);
  8. PORTB |=1 << PINB1;
  9.  
  10. int baud = 25;
  11. UBRRH = (unsigned char)(baud>>8);
  12. UBRRL = (unsigned char)baud;
  13.  
  14. UCSRB = (1<<RXEN)|(1<<TXEN);
  15. /* Set frame format: 8data, 2stop bit */
  16. UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0);
  17.  
  18. while(1){
  19. if(bit_is_clear(PINB,1)){
  20. if(pressed==0){
  21. PORTB |=1 << PINB0;
  22. while ( !( UCSRA & (1<<UDRE)) );
  23. UDR = data;
  24. pressed=1;
  25. }
  26. }
  27. else{
  28. PORTB &=~(1<<PINB0);
  29. pressed=0;
  30. }
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement