Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. AIUTO
  2.  
  3. static bool bSTART = 2;
  4. static bool bSTOP = 3; // pin A0
  5. const int E1 = 13; // pin 3
  6. const int E2 = 12; // pin 5
  7. const int E3 = 11; // pin 6
  8. int stato = 0;
  9. int Ingresso;
  10. int Ingresso1;
  11. int s;
  12. /* Ingresso=> 0 1
  13.  
  14. */
  15. const int Trans [21][2] = { 0, 19,
  16. 1, 19,
  17. 2, 19,
  18. 3, 19,
  19. 4, 19,
  20. 5, 19,
  21. 6, 19,
  22. 7, 19,
  23. 8, 19,
  24. 9, 19,
  25. 10, 19,
  26. 11, 19,
  27. 12, 19,
  28. 13, 19,
  29. 14, 19,
  30. 15, 19,
  31. 16, 19,
  32. 17, 19,
  33. 18, 19,
  34. 19, 20,
  35. 20, 19
  36. };
  37.  
  38.  
  39.  
  40. /* R G V T[ms] */
  41. const int on[18][4] = { 1, 0, 0, 5000,
  42. 0, 1, 0, 5000,
  43. 0, 0, 1, 5000,
  44. 0, 0, 0, 3000,
  45. 0, 0, 1, 5000,
  46. 0, 1, 0, 5000,
  47. 1, 0, 0, 5000,
  48. 0, 0, 0, 2000,
  49. 1, 1, 1, 3000,
  50. 0, 0, 0, 2000,
  51. 1, 1, 1, 3000,
  52. 0, 0, 0, 2000,
  53. 1, 1, 1, 3000,
  54. 0, 0, 0, 2000,
  55. 1, 1, 1, 3000,
  56. 0, 0, 0, 2000,
  57. 1, 1, 1, 3000,
  58. 0, 0, 0, 2000
  59. };
  60.  
  61. const int off [1][4] = { 0, 0, 0, 1000000000};
  62.  
  63.  
  64.  
  65. void setup() {
  66. // Serial.begin(9600);
  67. pinMode(bSTART, INPUT_PULLUP);
  68. pinMode(bSTOP, INPUT_PULLUP); // A0 come ingresso digitale con Pull-up
  69. pinMode(E1, OUTPUT);
  70. pinMode(E2, OUTPUT);
  71. pinMode(E3, OUTPUT);
  72. }
  73. void loop() {
  74.  
  75. Ingresso1 = digitalRead(bSTOP);
  76. Ingresso = digitalRead(bSTART);
  77.  
  78. if (Ingresso == true)
  79. {
  80. delay(on[stato][3]);
  81. stato = Trans[stato][Ingresso];
  82. digitalWrite(E1, on[s][0]);
  83. digitalWrite(E2, on[s][1]);
  84. digitalWrite(E3, on[s][2]);
  85. }
  86.  
  87. else
  88. {
  89.  
  90. }
  91.  
  92. if (Ingresso1 == true)
  93. {
  94. delay(off[stato][3]);
  95. stato = Trans[stato][Ingresso];
  96. digitalWrite(E1, off[s][0]);
  97. digitalWrite(E2, off[s][1]);
  98. digitalWrite(E3, off[s][2]);
  99. }
  100.  
  101. else
  102. {
  103.  
  104. }
  105.  
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement