I suspect what you want is a for loop. Not one line but close. You'll also need to read up on arrays. An array is where you store the pin numbers that the for loop will reference to do things like setting pinModes.
The IDE has examples at - File/examples/5.control.
jmatos448:
my question is, how can i get something like this??
digitalWrite(led0, led1, led2, HIGH);
Do you mean you want a function like:
void digitalWrite3( int a, int b, int c, int hilo )
{
digitalWrite( a, hilo );
digitalWrite( b, hilo );
digitalWrite( c, hilo );
}
//then in your setup(), you can call that function like:
digitalWrite3( led1, led2, led3, HIGH );
void digitalWrite3(const byte a, const byte b, const byte c, const bool hilo )
{
digitalWrite( a, hilo );
digitalWrite( b, hilo );
digitalWrite( c, hilo );
}
//then in your setup(), you can call that function like:
digitalWrite3( led1, led2, led3, HIGH );
Pin numbers are byte/uint8_t, not int. For dark reasons the value is a uint8_t as well but you just want to use HIGH/LOW / true/false so a bool will do.
But in reality, using arrays is the right way. The moment you start numbering stuff => arrays make it a lot easier.
I think that until the OP (hello?) comes back with more info, it's hard to say what he wants.
Loop? Array? - that's making a bit of an assumption.
Based on just what he asked, he could be asking how to write a variadic function...
Setting a random selection of LEDs by doing: setLeds( HIGH, led1 ) or setLeds( LOW, led1, led2, led4 ) might be handy. (*)
Yours,
TonyWilk
(*) but interesting if you're mixing int's and bytes for pin numbers, compiler's not going to coerce that for you - could just write multiple functions I suppose, messy tho'.