void setup() {
// Set pins 2 to 11 as OUTPUT
for (int i = 2; i <= 11; i++) {
pinMode(i, OUTPUT);
}
// Set pin 13 as INPUT
pinMode(13, INPUT);
}
void loop() {
// Check the state of pin 13
if (digitalRead(13) == HIGH) {
for (int i = 0; i < 5; i++) { // Loop 5 times
pat1(); // Call pat1 function 5 times
}
}
// Check the state of pin 13
if (digitalRead(13) == LOW) {
for (int i = 0; i < 5; i++) { // Loop 5 times
pat2(); // Call pat2 function 5 times
}
}
}
// Function pat1 definition
void pat1() {
// Example pattern for pat1: Turn on all lights from pin 2 to 11
for (int i = 2; i <= 11; i++) {
digitalWrite(i, HIGH); // Turn on the LED or reactive device on pin i
}
delay(500); // Wait for 500 milliseconds
for (int i = 2; i <= 11; i++) {
digitalWrite(i, LOW); // Turn off the LED or reactive device on pin i
}
delay(500); // Wait for 500 milliseconds
}
// Function pat2 definition
void pat2() {
// Example pattern for pat2: Blink all lights from pin 2 to 11
for (int i = 2; i <= 11; i++) {
digitalWrite(i, HIGH); // Turn on the LED or reactive device on pin i
}
delay(200); // Wait for 200 milliseconds
for (int i = 2; i <= 11; i++) {
digitalWrite(i, LOW); // Turn off the LED or reactive device on pin i
}
delay(200); // Wait for 200 milliseconds
}