Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. int motor1_dir1 = 12;
  2. int motor1_dir2 = 13;
  3. int motor1_pwm = 11;
  4.  
  5. int motor2_dir1 = 8;
  6. int motor2_dir2 = 7;
  7. int motor2_pwm = 10;
  8.  
  9. int motor3_dir1 = 5;
  10. int motor3_dir2 = 4;
  11. int motor3_pwm = 9;
  12.  
  13. int motor4_dir1 = 3;
  14. int motor4_dir2 = 2;
  15. int motor4_pwm = 6;
  16.  
  17.  
  18. void setup()
  19. {
  20. pinMode(motor1_dir1,OUTPUT);
  21. pinMode(motor1_dir2,OUTPUT);
  22. pinMode(motor1_pwm,OUTPUT);
  23.  
  24. pinMode(motor2_dir1,OUTPUT);
  25. pinMode(motor2_dir2,OUTPUT);
  26. pinMode(motor2_pwm,OUTPUT);
  27.  
  28. pinMode(motor3_dir1,OUTPUT);
  29. pinMode(motor3_dir2,OUTPUT);
  30. pinMode(motor3_pwm,OUTPUT);
  31.  
  32. pinMode(motor4_dir1,OUTPUT);
  33. pinMode(motor4_dir2,OUTPUT);
  34. pinMode(motor4_pwm,OUTPUT);
  35.  
  36. digitalWrite(motor1_dir1,0);
  37. digitalWrite(motor1_dir2,1);
  38. digitalWrite(motor1_pwm,1);
  39.  
  40. digitalWrite(motor2_dir1,0);
  41. digitalWrite(motor2_dir2,1);
  42. digitalWrite(motor2_pwm,1);
  43.  
  44. digitalWrite(motor3_dir1,0);
  45. digitalWrite(motor3_dir2,1);
  46. digitalWrite(motor3_pwm,1);
  47.  
  48. digitalWrite(motor4_dir1,0);
  49. digitalWrite(motor4_dir2,1);
  50. digitalWrite(motor4_pwm,1);
  51. }
  52. void loop()
  53. {
  54. analogWrite(motor1_pwm, 128);
  55. analogWrite(motor2_pwm, 128);
  56. analogWrite(motor3_pwm, 128);
  57. analogWrite(motor4_pwm, 128);
  58. delay(500);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement