Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. #include <reg52.h>
  2.  
  3. void delay(int n)
  4. {
  5.     while (n--);
  6. }
  7.  
  8. int main()
  9. {
  10.     P0 = 0x00;
  11.     P1 = 0xFF;
  12.    
  13.     while (1)
  14.     {
  15.         if (P1 & 0x1)
  16.         {
  17.             P0 = 0xFF;
  18.             delay(160000);
  19.             P0 = 0x00;
  20.             delay(160000);
  21.         } else
  22.         {
  23.             P0 = 0xFF;
  24.             delay(10000);
  25.             P0 = 0x00;
  26.             delay(10000);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement