C 29
Live Port shifting with difrent delay mega32 By Hightechrobo on 13th February 2025 10:14:53 AM
  1. #include <mega32.h>
  2. #include <delay.h>
  3.  
  4.  char a,b,c,d;
  5.  
  6.     void main(void)
  7.     {
  8.         int t1 = 0;
  9.        
  10.         DDRA = 0xFF ;
  11.         DDRB = 0xFF ;
  12.         DDRC = 0xFF ;
  13.         DDRD = 0xFF ;
  14.  
  15.     while (1)
  16.           {
  17.         if((t1 % 63) == 0 ){/////////////////PORTA shift
  18.                     PORTA = a;
  19.                      a <<= 1;
  20.                      if(a==0)
  21.                     a = 0b00000001;
  22.                     }
  23.          if((t1 % 171) == 0 ){/////////////////PORTB shift
  24.                     PORTB = b;
  25.                      b <<= 1;
  26.                      if(b==0)
  27.                     b = 0b00000001;
  28.                     }
  29.          if((t1 % 342) == 0 ){/////////////////PORTC shift
  30.                     PORTC = c;
  31.                      c <<= 1;
  32.                      if(c==0)
  33.                     c = 0b00000001;
  34.                     }
  35.          if((t1 % 511) == 0 ){/////////////////PORTD shift
  36.                     PORTD = d;
  37.                      d <<= 1;
  38.                      if(d==0)
  39.                     d = 0b00000001;
  40.                     t1 = 0;
  41.                     }
  42.  
  43.  
  44.  
  45.              delay_ms(1);
  46.              t1++;
  47.  
  48.     }   }

Hightechrobo bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.