Advertisement
ChaOSzz

Untitled

May 26th, 2022
914
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define PIN_ENA 8
  2. #define PIN_IN1 9
  3. #define PIN_IN2 10
  4. #define PIN_IN3 11
  5. #define PIN_IN4 12
  6. #define PIN_ENB 13
  7.  
  8. const int speed = 255;
  9. const int waitTime = 3000;
  10.  
  11. const int pinMotorA[3] = {PIN_ENA, PIN_IN1, PIN_IN2};
  12. const int pinMotorB[3] = {PIN_ENB, PIN_IN3, PIN_IN4};
  13.  
  14. void setup()
  15. {
  16.    pinMode(PIN_IN1, OUTPUT);  
  17.    pinMode(PIN_IN2, OUTPUT);  
  18.    pinMode(PIN_ENA, OUTPUT);  
  19.    pinMode(PIN_IN3, OUTPUT);  
  20.    pinMode(PIN_IN4, OUTPUT);  
  21.    pinMode(PIN_ENB, OUTPUT);  
  22.    delay(1000);
  23. }
  24.  
  25.  
  26. void loop()
  27. {
  28.  
  29. }
  30.  
  31. void moveForward(const int pinMotor[3], int speed)
  32. {  
  33.   digitalWrite(pinMotor[1], HIGH);  
  34.   digitalWrite(pinMotor[2], LOW);  
  35.   analogWrite(pinMotor[0], speed);
  36. }
  37.  
  38. void moveBackward(const int pinMotor[3], int speed)
  39. {
  40.     digitalWrite(pinMotor[1], LOW);
  41.     digitalWrite(pinMotor[2], HIGH);
  42.     analogWrite(pinMotor[0], speed);
  43. }
  44.  
  45. void fullStop(const int pinMotor[3])
  46. {  
  47.   analogWrite(pinMotor[0], 0);
  48. }
Advertisement
RAW Paste Data Copied
Advertisement