Advertisement
elektronek

attiny13a - rele + tlacitko

May 7th, 2020
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. /*
  2.  * t13-tlacitko-rele.c
  3.  *
  4.  * Created: 07.05.2020 12:53:28
  5.  * Author : martin
  6.  */
  7.  
  8. #include <avr/io.h>
  9. #define RELE_ON     PORTB|=(1<<PB0);
  10. #define RELE_OFF    PORTB&=~(1<<PB0);
  11. uint8_t stateTl=0;
  12. uint8_t stateOut=0;
  13.  
  14. int main(void)
  15. {
  16.     DDRB|=(1<<PB0);     // PB0 - vystup
  17.     PORTB|=(1<<PB2);    // PB2 vstup proti zemi
  18.     while (1)
  19.     {
  20.         if (!(PINB&(1<<PB2)) && stateTl==1)
  21.         {
  22.             stateTl=0;
  23.             if (stateOut)
  24.                 { stateOut=0;   RELE_OFF;}
  25.             else
  26.                 { stateOut=1; RELE_ON; }
  27.         }
  28.         if (PINB&(1<<PB2)) stateTl=1;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement