Mpc1055
1
I am looking for a way to define a variable that controls multiple pins.
I have leds on pins 3,4,5,6,7 and I would like to combine them into one variable that I could use with digitalWrite to turn all the leds on at once...
Something like digitalWrite(lights, HIGH) and all 5 pins go HIGH.
Thanks!
Do some research on port manipulation
Make a function:
void turnAllLEDsOn() {
for (int i = 3; i <= 7; i++) {
digitalWrite(i, HIGH);
}
}
Mpc1055
4
Thanks, I thought about creating a function like that, the problem is I want them to turn off simultaneously! Thanks for the response though!
gfvalvo
5
Mpc1055:
Thanks, I thought about creating a function like that, the problem is I want them to turn off simultaneously!
What's your time scale for "simultaneously"? I guarantee you that effect produced by the function Reply #2 will look simultaneous to any mere mortal.