plugin23

4

Feb 10th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. /*
  2.  * zadanie3.c
  3.  *
  4.  * Created: 22.10.2015 11:45:17
  5.  *  Author: d14valicek
  6.  */
  7.  
  8. #define F_CPU 1000000UL
  9. #include <avr/io.h>
  10. #include <stdio.h>
  11. #include <util/delay.h>
  12.  
  13. int main(void)
  14. {
  15.     DDRD = 0xFF; //vystup
  16.     DDRC = 0x00; //vstup
  17.     while(1)
  18.     {
  19.         if (bit_is_clear(PINC, 0))
  20.         {
  21.             for(int c = 1; c <= 256; c=(c*2))
  22.             {
  23.                 int a = c - 1;
  24.                 PORTD =~a;
  25.                 _delay_ms(500);
  26.             }
  27.         }
  28.         else if (bit_is_set(PINC, 0))
  29.         {
  30.             for(int c = 256; c >= 1; c=(c/2))
  31.             {
  32.                 int a = c - 1;
  33.                 PORTD = ~a;
  34.                 _delay_ms(500);
  35.             }
  36.            
  37.         }
  38.     }
  39.    
  40.     return 0;
  41. }
Add Comment
Please, Sign In to add comment