Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. #include <REGX52.H>
  2.  
  3. #define In1 P2_1
  4. #define In2 P2_2
  5. #define En1 P2_3
  6. #define In3 P2_5
  7. #define In4 P2_6
  8. #define En2 P2_4
  9. int rotator=0;
  10. int counter=0;
  11. int silnik=1;
  12.  
  13. void ISR_Timer1()interrupt 3{
  14. //if(silnik==1){
  15. if(counter<7){
  16. En1=1;
  17. counter ++;
  18. }
  19. else{
  20. En1=0;
  21. counter ++;
  22. }
  23. //}
  24. // if(silnik==2){
  25. if(counter<7){
  26. En2=1;
  27. counter ++;
  28. }
  29. else{
  30. En2=0;
  31. counter ++;
  32. }
  33. // }
  34. counter=counter%8;
  35. }
  36.  
  37. void ISR_INT1() interrupt 2{
  38. rotator++;
  39. if(rotator==10){
  40. En1=0;
  41. En2=1;
  42. silnik=2;
  43. rotator=0;
  44. }
  45. }
  46.  
  47. void ISR_INT0() interrupt 0{
  48.  
  49.  
  50.  
  51. }
  52.  
  53. void Setup(){
  54. En1=1;
  55. In1=0;
  56. In2=1;
  57.  
  58. En2=0;
  59. In3=1;
  60. In4=0;
  61.  
  62. TMOD=0x02;
  63. TH0=TL0=0x00;
  64. ET1=1;
  65. ET0=1;
  66. EA=1;
  67. EX0=IT0=1;
  68. EX1=IT1=1;
  69. TR0=1;
  70.  
  71. }
  72. void main(){
  73. Setup();
  74. while(1){
  75.  
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement