marichan022

URS_L07Z05

Nov 30th, 2019
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #define F_CPU 7372800UL
  2.  
  3. #include <avr/io.h>
  4. #include <util/delay.h>
  5.  
  6. void blink(uint8_t cnt) {
  7.     if (cnt <= 3) {
  8.         PORTA = PORTA & ~_BV(cnt) & ~_BV(7-cnt);
  9.     } else {
  10.         cnt %= 4;
  11.         PORTA = PORTA | _BV(cnt+4) | _BV(3-cnt);
  12.     }
  13. }
  14.  
  15. int main(void) {
  16.     DDRA = 0xff;
  17.     PORTA = 0xff;
  18.     uint8_t cnt = 0;
  19.  
  20.     while (1) {
  21.         blink(cnt);
  22.         cnt = (cnt + 1) % 8;
  23.     //  _delay_ms(325);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment