Alx09

Untitled

Mar 8th, 2021
568
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×