Guest User

Untitled

a guest
Nov 13th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. int switchPin = 2;
  2. int enablePin = 9;
  3. int motor1Pin = 3;
  4. int motor2Pin = 4;
  5.  
  6. void setup() {
  7. // put your setup code here, to run once:
  8.  
  9. pinMode(switchPin, INPUT);
  10. pinMode(enablePin, OUTPUT);
  11. pinMode(motor1Pin, OUTPUT);
  12. pinMode(motor2Pin, OUTPUT);
  13.  
  14. digitalWrite(enablePin,HIGH);
  15.  
  16. Serial.begin(9600);
  17.  
  18. }
  19.  
  20. void loop() {
  21. // put your main code here, to run repeatedly:
  22. int switchVal = digitalRead(switchPin);
  23. Serial.println(switchVal);
  24. if(switchVal == HIGH){
  25. digitalWrite(motor1Pin, HIGH);
  26. digitalWrite(motor2Pin, LOW);
  27. }
  28. else{
  29. digitalWrite(motor1Pin, LOW);
  30. digitalWrite(motor2Pin, HIGH);
  31. }
  32.  
  33. }
Add Comment
Please, Sign In to add comment