Advertisement
marichan022

URS_K02G01Z02

Dec 3rd, 2019
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 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(4+cnt) & ~_BV(3-cnt);
  9.     } else {
  10.         cnt = cnt % 4;
  11.         PORTA = PORTA | _BV(4+cnt) | _BV(3-cnt);
  12.     }
  13. }
  14.  
  15. int main() {
  16.     DDRA = 0xff;
  17.     PORTA = 0xff;
  18.  
  19.     uint8_t cnt = 0;
  20.     while (1) {
  21.         blink(cnt);
  22.         cnt = (cnt+1) % 8;
  23.         _delay_ms(200);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement