tilz0R

pinstate

Aug 6th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. //funkcija
  2. void pinstate(uint8_t port, uint8_t pin, uint8_t state) {  
  3.     if (state == 0) {
  4.         port &= ~(1 << pin);
  5.     } else {
  6.         port |= (1 << pin);
  7.     }
  8. }
  9.  
  10. //Uporaba
  11. pinstate(PORTB, PINB0, 1);
  12.  
  13. //ProgramĨek, kjer NE dela (brez headerja)
  14. int main(void) {
  15.     uart_init(9600);
  16.     uart_putsln("haj");
  17.     pinstate(DDRB, PINB0, 1); //ne dela
  18.     DDRB = 0xFF; //dela
  19.         while (1) {
  20.         pinstate(PORTB, PINB0, 1); //ne dela
  21.         //PORTB |= 1 << PINB0; //dela
  22.         _delay_ms(200);
  23.         pinstate(PORTB, PINB0, 0); //ne dela
  24.         //PORTB &= ~(1 << PINB0); // dela
  25.         _delay_ms(200);
  26.         }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment