Drawbridge / Sailer stepper motor - mcworkshop

MC        WORKSHOP
Vai ai contenuti

Menu principale:

Drawbridge / Sailer stepper motor

Projects
//IN1 pin8, IN2 pin9, IN3 pin 10, IN4 pin11
// Ponte levatoio / Barca a vela 22/03/2020
int button_1 = 2;
int button_2 = 3;
int mP1 = 8;
int mP2 = 9;
int mP3 = 10;
int mP4 = 11;
int mSp = 5;
int motor_Step;
int val1 = 0;
int val2 = 0;
void setup() {
 pinMode(button_1, INPUT);
 pinMode(button_2, INPUT);
 pinMode(mP1, OUTPUT);
 pinMode(mP2, OUTPUT);
 pinMode(mP3, OUTPUT);
 pinMode(mP4, OUTPUT);
}
void loop() {
 val1 = digitalRead(button_1);
 if (val1 == HIGH)
 {
   digitalWrite(mP1, HIGH);
   digitalWrite(mP2, LOW);
   digitalWrite(mP3, LOW);
   digitalWrite(mP4, LOW);
   delay(mSp);
   digitalWrite(mP1, LOW);
   digitalWrite(mP2, HIGH);
   digitalWrite(mP3, LOW);
   digitalWrite(mP4, LOW);
   delay(mSp);
   digitalWrite(mP1, LOW);
   digitalWrite(mP2, LOW);
   digitalWrite(mP3, HIGH);
   digitalWrite(mP4, LOW);
   delay(mSp);
   digitalWrite(mP1, LOW);
   digitalWrite(mP2, LOW);
   digitalWrite(mP3, LOW);
   digitalWrite(mP4, HIGH);
   delay(mSp);
 }
 val2 = digitalRead(button_2);
 if (val2 == HIGH)
 {
   digitalWrite(mP1, HIGH);
   digitalWrite(mP2, LOW);
   digitalWrite(mP3, LOW);
   digitalWrite(mP4, LOW);
   delay(mSp);
   digitalWrite(mP1, LOW);
   digitalWrite(mP2, LOW);
   digitalWrite(mP3, LOW);
   digitalWrite(mP4, HIGH);
   delay(mSp);
   digitalWrite(mP1, LOW);
   digitalWrite(mP2, LOW);
   digitalWrite(mP3, HIGH);
   digitalWrite(mP4, LOW);
   delay(mSp);
   digitalWrite(mP1, LOW);
   digitalWrite(mP2, HIGH);
   digitalWrite(mP3, LOW);
   digitalWrite(mP4, LOW);
   delay(mSp);
 }
}
clic to enlarge
 
Copyright 2015. All rights reserved.
Torna ai contenuti | Torna al menu