Created
May 3, 2024 18:20
-
-
Save EllieTheYeen/e9c2cad8b91b2fa02486bdaa47f92ffb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t state = 0, s = 0; | |
uint8_t pin[] = { A4, A5, 2 }; | |
void setup() { | |
} | |
void loop() { | |
for (int i = 0; i < sizeof(pin); i++) { | |
s = (state & (3 << (2 * i))) >> (2 * i); | |
if (s == 2) { | |
pinMode(pin[i], INPUT); | |
} else if (s == 3) { | |
pinMode(pin[i], INPUT_PULLUP); | |
} else { | |
pinMode(pin[i], OUTPUT); | |
digitalWrite(pin[i], s); | |
} | |
} | |
state++; | |
delay(50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment