Advertisement
Alx09

Untitled

Mar 8th, 2021
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. unsigned char old = 0;
  2. unsigned char dat = 0;
  3. void setup()
  4. {
  5.     DDRD = 0xFF;
  6.     DDRB = 0xFF;
  7.     DDRC = 0x00;
  8.    
  9.     PORTD = 0x01;
  10.     PORTB = 0x00;
  11. }
  12. void loop()
  13. {
  14.    
  15.     if((PINC&0x01) && !old)
  16.     {
  17.       if(!dat)
  18.       {
  19.         if(PORTD < 0x80)
  20.         {
  21.             PORTD <<= 0x01;
  22.         }
  23.         else
  24.         {
  25.             PORTB = 0x01;
  26.             PORTD = 0x00;
  27.             dat = 1;
  28.         }
  29.       }
  30.       else
  31.       {
  32.         if(PORTB < 0x20)
  33.         {
  34.             PORTB <<= 0x01;
  35.         }
  36.         else
  37.         {
  38.             PORTB = 0x00;
  39.             PORTD = 0x01;
  40.             dat = 0;
  41.         }  
  42.       }
  43.     }
  44.     old = PINC&0x01;
  45.     delay(20);     
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement