CPP 85
ARDUINO MOTOR By theneedyguy on 23rd May 2017 02:28:11 PM
  1. int MOT_L = 10;
  2. int MOT_R = 5;
  3. int MOT_L_REV = 9;
  4. int MOT_L_VOR = 8;
  5. int MOT_R_VOR = 7;
  6. int MOT_R_REV = 6;
  7.  
  8.  
  9.  
  10. void setup() {
  11.   // put your setup code here, to run once:
  12. pinMode(MOT_L,OUTPUT);
  13. pinMode(MOT_L_VOR,OUTPUT);
  14. pinMode(MOT_L_REV,OUTPUT);
  15. pinMode(MOT_R,OUTPUT);
  16. pinMode(MOT_R_VOR,OUTPUT);
  17. pinMode(MOT_R_REV,OUTPUT);
  18.  
  19.  
  20. }
  21.  
  22. void loop() {
  23.   // put your main code here, to run repeatedly:
  24. halt(MOT_L, MOT_R, MOT_L_VOR, MOT_L_REV, MOT_R_VOR, MOT_R_REV, 2000);
  25. forward(MOT_L, MOT_R, MOT_L_VOR, MOT_L_REV, MOT_R_VOR, MOT_R_REV, 1000);
  26. halt(MOT_L, MOT_R, MOT_L_VOR, MOT_L_REV, MOT_R_VOR, MOT_R_REV, 2000);
  27. reverse(MOT_L, MOT_R, MOT_L_VOR, MOT_L_REV, MOT_R_VOR, MOT_R_REV, 1000);
  28. halt(MOT_L, MOT_R, MOT_L_VOR, MOT_L_REV, MOT_R_VOR, MOT_R_REV, 1000);
  29. kreis(MOT_L, MOT_R, MOT_L_VOR, MOT_L_REV, MOT_R_VOR, MOT_R_REV, 255, 255, 5000);
  30. halt(MOT_L, MOT_R, MOT_L_VOR, MOT_L_REV, MOT_R_VOR, MOT_R_REV, 1000);
  31. kreis(MOT_L, MOT_R, MOT_L_VOR, MOT_L_REV, MOT_R_VOR, MOT_R_REV, 255, 255, 5000);
  32. }
  33.  
  34. void forward(int POW_L, int POW_R, int SIG_L_VOR, int SIG_L_REV, int SIG_R_VOR, int SIG_R_REV, int DELAY){
  35.   digitalWrite(POW_L, HIGH);
  36.   digitalWrite(POW_R, HIGH);
  37.   digitalWrite(SIG_L_REV, LOW);
  38.   digitalWrite(SIG_R_REV, LOW);
  39.   digitalWrite(SIG_L_VOR, HIGH);
  40.   digitalWrite(SIG_R_VOR, HIGH);
  41.   delay(DELAY);
  42. }
  43. void reverse(int POW_L, int POW_R, int SIG_L_VOR, int SIG_L_REV, int SIG_R_VOR, int SIG_R_REV, int DELAY){
  44.   digitalWrite(POW_L, HIGH);
  45.   digitalWrite(POW_R, HIGH);
  46.   digitalWrite(SIG_L_REV, HIGH);
  47.   digitalWrite(SIG_R_REV, HIGH);
  48.   digitalWrite(SIG_L_VOR, LOW);
  49.   digitalWrite(SIG_R_VOR, LOW);
  50.   delay(DELAY);
  51. }
  52.  
  53. void halt(int POW_L, int POW_R, int SIG_L_VOR, int SIG_L_REV, int SIG_R_VOR, int SIG_R_REV, int DELAY){
  54.   digitalWrite(POW_L, HIGH);
  55.   digitalWrite(POW_R, HIGH);
  56.   digitalWrite(SIG_L_REV, LOW);
  57.   digitalWrite(SIG_R_REV, LOW);
  58.   digitalWrite(SIG_L_VOR, LOW);
  59.   digitalWrite(SIG_R_VOR, LOW);
  60.   delay(DELAY);
  61. }
  62.  
  63. void kreis(int POW_L, int POW_R, int SIG_L_VOR, int SIG_L_REV, int SIG_R_VOR, int SIG_R_REV, int KREIS_L, int KREIS_R, int DELAY){
  64.   analogWrite(POW_L, KREIS_L);
  65.   analogWrite(POW_R, KREIS_R);
  66.   digitalWrite(SIG_L_REV, LOW);
  67.   digitalWrite(SIG_R_REV, LOW);
  68.   digitalWrite(SIG_L_VOR, HIGH);
  69.   digitalWrite(SIG_R_VOR, HIGH);
  70.   delay(DELAY);
  71. }

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.