Advertisement
zdenekpetrzd

Motor

Mar 20th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. int pinMotor[] = {12, 11, 10, 9};
  2. int poziceMot[8][4] = {
  3. {0,0,0,1},
  4. {0,0,1,1},
  5. {0,0,1,0},
  6. {0,1,1,0},
  7. {0,1,0,0},
  8. {1,1,0,0},
  9. {1,0,0,0},
  10. {1,0,0,1},
  11. };
  12.  
  13. void otaceni(int smer) {
  14. while(smer > 0) {
  15. for(int i = 0; i < 8; i++) {
  16. for(int d = 0; d < 4; d++) {
  17. digitalWrite(pinMotor[d], poziceMot[i][d]);
  18. }
  19. delayMicroseconds(900);
  20. }
  21. Serial.println(smer);
  22. smer--;
  23. }
  24. while(smer < 0){
  25. for(int i = 8; i > 0; i--) {
  26. for(int d = 0; d < 4; d++) {
  27. digitalWrite(pinMotor[d], poziceMot[i][d]);
  28. }
  29. delayMicroseconds(900);
  30. }
  31. smer++;
  32. Serial.println(smer);
  33. }
  34. }
  35.  
  36. void setup() {
  37. Serial.begin(115200);
  38. Serial.println("Jsen tuL");
  39. for(int i = 0; i < 4; i++) {
  40. pinMode(pinMotor[i], OUTPUT);
  41. }
  42.  
  43. }
  44.  
  45. void loop() {
  46. otaceni(10);
  47. otaceni(-10);
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement