Advertisement
marichan022

URS_L07Z06

Nov 30th, 2019
280
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 == 0) {
  8.         PORTA = 0xff;
  9.     } else if (cnt % 2 == 1) {
  10.         PORTA = ~_BV(cnt/2);
  11.     } else {
  12.         PORTA = ~_BV(8-cnt/2);
  13.     }
  14. }
  15.  
  16. int main(void) {
  17.     DDRA = 0xff;
  18.     PORTA = 0xff;
  19.     uint8_t cnt = 0;
  20.    
  21.     while (1) {
  22.         blink(cnt);
  23.         cnt = (cnt + 1) % 9;
  24.     //  _delay_ms(325);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement