Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement