Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. // #define __AVR_ATmega8__
  2. #define F_CPU 8000000UL  /* 1 MHz CPU clock */
  3. #include <util/delay.h>
  4. #include <avr/io.h>
  5.  
  6. int main() {
  7.     DDRB = 0xFF; // LED output
  8.     DDRD = 0x00; // Switch input
  9.     PORTB = 2;
  10.     for (;;) {
  11.         // condition ? value if true : value if false
  12.         //PORTB = PORTD ? 2 : 1;
  13.  
  14.         //PORTB = PIND ? 2 : 1;
  15.  
  16.         if (PIND & (0x01))
  17.             PORTB = 0x01;
  18.         else
  19.             PORTB = 0x00;
  20.     }
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement