Advertisement
gabbyshimoni

moveDCCW-CCW

Feb 6th, 2019
1,247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. // Gabby Shimoni 02062019
  2. // Move DC motor back and forth
  3.  
  4. #define motorInPin1 7
  5. #define motorInPin2 8
  6. void setup() {
  7.   pinMode(motorInPin1,OUTPUT);
  8.   pinMode(motorInPin2,OUTPUT);
  9. }
  10.  
  11. void loop() {
  12.   // turn clockwise
  13.   digitalWrite(motorInPin1,HIGH);
  14.   digitalWrite(motorInPin2,LOW);
  15.   delay(1000);
  16.  
  17.   // stop motor
  18.   digitalWrite(motorInPin1,LOW);
  19.   digitalWrite(motorInPin2,LOW);
  20.   delay(1000);
  21.  
  22.   // turn anti-clockwise
  23.   digitalWrite(motorInPin1,LOW);
  24.   digitalWrite(motorInPin2,HIGH);
  25.   delay(1000);
  26.  
  27.   // stop motor
  28.   digitalWrite(motorInPin1,LOW);
  29.   digitalWrite(motorInPin2,LOW);
  30.   delay(1000);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement