С этим скетчем проблема, сразу срабатывают все реле, а этого не должно быть. Код (C++): int relayPin1 = 3; int relayPin2 = 4; int relayPin3 = 5; int relayPin4 = 6; int relayPin5 = 7; void setup() { pinMode(relayPin1, OUTPUT); pinMode(relayPin2, OUTPUT); pinMode(relayPin3, OUTPUT); pinMode(relayPin4, OUTPUT); pinMode(relayPin5, OUTPUT); } void loop() { Serial.println("starting"); digitalWrite(relayPin1, LOW); delay(100); digitalWrite(relayPin1, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin2, LOW); delay(100); digitalWrite(relayPin2, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin3, LOW); delay(100); digitalWrite(relayPin3, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin4, LOW); delay(100); digitalWrite(relayPin4, HIGH); delay(2000); Serial.println("starting"); digitalWrite(relayPin4, LOW); delay(100); digitalWrite(relayPin4, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin2, LOW); delay(100); digitalWrite(relayPin2, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin1, LOW); delay(100); digitalWrite(relayPin1, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin3, LOW); delay(100); digitalWrite(relayPin3, HIGH); delay(2000); Serial.println("starting"); digitalWrite(relayPin1, LOW); delay(100); digitalWrite(relayPin1, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin2, LOW); delay(100); digitalWrite(relayPin2, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin3, LOW); delay(100); digitalWrite(relayPin3, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin4, LOW); delay(100); digitalWrite(relayPin4, HIGH); delay(2000); Serial.println("starting"); digitalWrite(relayPin4, LOW); delay(100); digitalWrite(relayPin4, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin2, LOW); delay(100); digitalWrite(relayPin2, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin1, LOW); delay(100); digitalWrite(relayPin1, HIGH); delay(1000); Serial.println("starting"); digitalWrite(relayPin3, LOW); delay(100); digitalWrite(relayPin3, HIGH); delay(2000); Serial.println("starting"); digitalWrite(relayPin5, LOW); delay(100); digitalWrite(relayPin5, HIGH); delay(3000); Serial.println("starting"); digitalWrite(relayPin5, LOW); delay(100); digitalWrite(relayPin5, HIGH); delay(3000); Serial.println("starting"); digitalWrite(relayPin5, LOW); delay(100); digitalWrite(relayPin5, HIGH); delay(3000); }
У вас в каком состоянии пины перед переключением в OUTPUT? HIGH? LOW? Код (C++): void setup() { pinMode(relayPin1, OUTPUT); pinMode(relayPin2, OUTPUT); pinMode(relayPin3, OUTPUT); pinMode(relayPin4, OUTPUT); pinMode(relayPin5, OUTPUT); }
при первом включении загораются все светодиоды на плате реле с 1 по 5, дальше надо подождать когда пройдет полный цикл и после этого программа дальше работает так как надо.