Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.38 KB | None | 0 0
  1.  //lecon younes_pic:
  2.        
  3.         //  set direction of RBO to output OxFE = 11111110 all other pins (RB1 - RB7) are input pins
  4.        
  5.        int i = 0 ;
  6.         unsigned  i =1;
  7.      void main() {
  8.      TRISB = 0x00;                // Set RB0 to high 00000001
  9.       PORTB = 1;
  10.      
  11.                         //while(1)
  12.                              // {
  13.      for(i=0;i<3;++i)
  14.     {
  15.                      //TRISB = 0x00;                // Set RB0 to high 00000001
  16.                         // PORTB = 1;
  17.     do                        // To set infinite loop
  18.     {
  19.       Delay_ms(300);          // 350 mili seconds delay
  20.       PORTB = PORTB<<1;       //Shifting right by one bit
  21.       if(PORTB >= 127 )    //0b10000000) //To reset to 00000001 when the count becomes 10000000
  22.       {
  23.          Delay_ms(300);       // 350 mili seconds delay
  24.          PORTB = 1;
  25.         break;
  26.       }
  27.      
  28.     }while(1);
  29.          PORTB = 0;
  30.          PORTB = 128;
  31.          do              // To set infinite loop
  32.     {
  33.       Delay_ms(300);          // 350 mili seconds delay
  34.       PORTB = PORTB>>1;       //Shifting right by one bit
  35.       if(PORTB == 1 )    //0b10000000) //To reset to 00000001 when the count becomes 10000000
  36.       {
  37.          Delay_ms(300);       // 350 mili seconds delay
  38.          PORTB = 0;
  39.        break;
  40.       }
  41.  
  42.     }while(1);
  43.  
  44.        
  45.        // To set infinite loop
  46. }   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement