18 Ocak 2016 Pazartesi

ARDUINO YENI BASLAYANLARA.....H KOPRU

H KÖPRÜ MOTOR

MOTOR BUTONA BASINCA  5 SN SAĞ 3 SN BEKLE 7 SN SOLA DÖNECEK DURACAK

int digitalOutPin0 = 12;
int digitalOutPin1 = 10;
int digitalOutPin2 = 5;
int digitalOutPin3 = 3;
int digitalInPin1 = 2;



void setup() {
  Serial.begin(9600);
  pinMode(digitalInPin1, INPUT_PULLUP);
  pinMode(digitalOutPin0, OUTPUT);
  pinMode(digitalOutPin1, OUTPUT);
  pinMode(digitalOutPin2, OUTPUT);
  pinMode(digitalOutPin3, OUTPUT);
  digitalWrite(digitalOutPin0, LOW);
  digitalWrite(digitalOutPin1, LOW);
  digitalWrite(digitalOutPin2, LOW);
  digitalWrite(digitalOutPin3, LOW);
}
void loop() {
int button = digitalRead(digitalInPin1);
  if (button == LOW) {
    digitalWrite(digitalOutPin0, HIGH);
    digitalWrite(digitalOutPin2, HIGH);
   digitalWrite(digitalOutPin1, LOW);
    digitalWrite(digitalOutPin3, LOW);
    delay(5000);
    digitalWrite(digitalOutPin0, LOW);
    digitalWrite(digitalOutPin2, LOW);
    digitalWrite(digitalOutPin1, LOW);
    digitalWrite(digitalOutPin3, LOW);
    delay(3000);
    digitalWrite(digitalOutPin1, HIGH);
    digitalWrite(digitalOutPin3, HIGH);
    digitalWrite(digitalOutPin0, LOW);
    digitalWrite(digitalOutPin2, LOW);
    delay(7000);

    digitalWrite(digitalOutPin1, LOW);
    digitalWrite(digitalOutPin3, LOW);
    digitalWrite(digitalOutPin0, LOW);
    digitalWrite(digitalOutPin2, LOW);
  }
  else {
    digitalWrite(digitalOutPin0, LOW);
    digitalWrite(digitalOutPin1, LOW);
    digitalWrite(digitalOutPin2, LOW);
    digitalWrite(digitalOutPin3, LOW);
  }
}

Hiç yorum yok: