Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #include <89c51rd2.h>
  2. #define LEDS P2
  3. typedef unsigned short int WORD;
  4. typedef unsigned char BYTE;
  5.  
  6. void Diody_w_lewo(void);
  7. void Diody_w_prawo(void);
  8. void Delay1(WORD);
  9.  
  10.  
  11. void main (void)
  12. {
  13. unsigned int przycisk0=0;
  14. unsigned int przycisk7=0;
  15. BYTE k=1;
  16. BYTE i=0x80;
  17. while(1)
  18. {
  19. if(P3_0==0 || przycisk0==1)
  20. {
  21. przycisk7=0;
  22. przycisk0=1;
  23. //i=1;
  24. LEDS=~k;
  25. k= (k==0x80 ) ? 1 : k<<1;
  26. Delay1(0x1FFF);
  27. Delay1(0x1FFF);
  28.  
  29. }
  30.  
  31.  
  32. if (P3_7==0 || przycisk7==1)
  33. {
  34. przycisk7=1;
  35. przycisk0=0;
  36.  
  37. //i=0x80;
  38. LEDS=~i;
  39. i= (i==1) ? 0x80 : i>>1;
  40. Delay1(0x1FFF);
  41. Delay1(0x1FFF);
  42.  
  43. }
  44.  
  45.  
  46. }
  47.  
  48.  
  49. }
  50.  
  51. void Delay1 (WORD wait )
  52. {
  53. WORD i;
  54. for(i=0;i<wait;i++){};
  55. }
  56.  
  57.  
  58. void Diody_w_lewo(void)
  59. {
  60. x=1;
  61. static BYTE i=1;
  62. LEDS=~i;
  63. i= (i==0x80 ) ? 1 : i<<1;
  64. Delay1(0x1FFF);
  65. Delay1(0x1FFF);
  66. }
  67.  
  68. void Diody_w_prawo(void)
  69. {
  70. y=1;
  71. static BYTE i=0x80;
  72. LEDS=~i;
  73. i= (i==1) ? 0x80 : i>>1;
  74. Delay1(0x1FFF);
  75. Delay1(0x1FFF);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement