Advertisement
tamarin_vs19

display3

Nov 17th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <util/delay.h>
  3.  
  4.  
  5. void main() {
  6.     DDRB  = 0b00000000;
  7.     PORTB = 0b00000001;
  8.     DDRA  = 0b11111111;
  9.     PORTA = 0b00000001;
  10.  
  11.     int dir = 1;
  12.     int num = 0;
  13.     while (1) {
  14.         if (!(PINB & 0b00000001)) {
  15.             dir *= -1;
  16.         }
  17.         PORTA = 1 << num;
  18.         _delay_ms (100);
  19.         num = (num + 1*dir + 8) % 8;
  20.     }
  21. }
  22.  
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement