lucasmcg

motor_test_10-21-21_incomplete

Oct 21st, 2021
864
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 10-21-21 L293D Motor Control Sketch
  2. // Lucas McGuire
  3.  
  4. // declare variables
  5. byte enablePin = 3; // Connect to chip pin 1
  6. byte turnLeft = 4; // Connect to chip pin 2 (1A)
  7. byte turnRight = 5; // Connect to chip pin 7 (2A)
  8.  
  9. byte enableButton = 6;
  10. byte rightButton = 7;
  11. byte leftButton = 8;
  12.  
  13. boolean enableButton_state = LOW;
  14. boolean rightButton_state = LOW;
  15. boolean leftButton_state = LOW;
  16.  
  17. void setup()
  18. {
  19.   Serial.begin(9600);
  20.   Serial.println("Running Motor Control Sketch");
  21.   pinMode(enablePin, OUTPUT);
  22.   pinMode(turnLeft, OUTPUT);
  23.   pinMode(turnRight, OUTPUT);
  24.  
  25.   pinMode(enableButton, INPUT);
  26.   pinMode(rightButton, INPUT);
  27.   pinMode(leftButton, INPUT);
  28.  
  29. }
  30.  
  31. void loop()
  32. {
  33.   if (digitalRead(enableButton))
  34.   {
  35.     enableButton_state = !enableButton_state;
  36.     if (enableButton)
  37.     {
  38.       digitalWrite(enablePin, HIGH);
  39.     }
  40.      else
  41.      {
  42.       digitalWrite(enablePin, LOW);
  43.      }
  44.     Serial.println(enableButton_state);
  45.   }
  46. }
RAW Paste Data