gabbyshimoni icon

moveDCCW-CCW

gabbyshimoni | PRO | 02/06/19 01:37:22 PM UTC | 0 ⭐ | 1823 👁️ | Never ⏰ | []
C++ |

630 B

|

None

|

0 👍

/

0 👎

// Gabby Shimoni 02062019
// Move DC motor back and forth
 
#define motorInPin1 7
#define motorInPin2 8
void setup() {
  pinMode(motorInPin1,OUTPUT);
  pinMode(motorInPin2,OUTPUT);
}
 
void loop() {
  // turn clockwise
  digitalWrite(motorInPin1,HIGH);
  digitalWrite(motorInPin2,LOW);
  delay(1000);
  
  // stop motor
  digitalWrite(motorInPin1,LOW);
  digitalWrite(motorInPin2,LOW);
  delay(1000);
  
  // turn anti-clockwise
  digitalWrite(motorInPin1,LOW);
  digitalWrite(motorInPin2,HIGH);
  delay(1000);
  
  // stop motor
  digitalWrite(motorInPin1,LOW);
  digitalWrite(motorInPin2,LOW);
  delay(1000);
}

Comments