Advertisement
Momir

DeRxPic

May 26th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #define DELAY 2
  2. int zn;
  3. int i;
  4.  
  5. void main()
  6. {
  7.     ANSELC = 0;
  8.     TRISC = 16;
  9.     UART1_Init(38400);
  10.  
  11.     while(1)
  12.     {
  13.         zn = 0;
  14.  
  15.         if(PORTC & 16)
  16.         {
  17.             Delay_ms(3);
  18.  
  19.             for(i = 0; i < 8; i++)
  20.             {
  21.                 if(PORTC & 16)
  22.                 {
  23.                     zn = (zn << 1) | 1;
  24.                     LATB = 1;
  25.                 }
  26.                 else
  27.                 {
  28.                     zn <<= 1;
  29.                     LATB = 0;
  30.                 }
  31.  
  32.                 Delay_ms(2);
  33.             }
  34.  
  35.             LATB = 0;
  36.             UART1_Write(zn);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement