Hello my question is regarding the syntax involving arrays and digitalWrite.
I was trying to have it simply written like this:
digitalWrite(oneArray[0, 1, 2, 3], HIGH);
It partially works, and by that I mean it recognizes only the very last part of the array, 3.
I have a hunch there is no way to use more than one pin per line for digitalWrite for it to follow, but if that isn't the case could someone provide me with some method or syntax that would work?
I'm basically trying to assign a HIGH value to more than 1 pin on a SINGLE line of code with one digitalWrite or something equivalent.
What's wrong with a for loop? Is it truly necessary to have the outputs change at the EXACT same time, or is a couple of microseconds delay between them acceptable?
If you truly need them to change at the same time, you need direct port manipulation like AWOL said. but first you should figure out if you truly need it.
What's your goal? Fast code, concise code or compact code? Or just figuring out a different way of doing something?
If your goal is speed, look into direct port manipulation.
If you want concise code, a for/next loop would work just as well. If you want compact code, you may have to play around since concise code is often not any smaller after it is compiled.
S-man:
I'm basically trying to assign a HIGH value to more than 1 pin on a SINGLE line of code with one digitalWrite or something equivalent.
And here's another telling you to use direct port manipulation.
Each pin is 1 bit. You make a byte to set the port, not an array of bytes.
If you are not changing all 8 bits then you need to copy the port and only change the ones you want.
On an UNO, none of the ports have 8 bits open for use. 6 is the maximum. But a MEGA has full ports open to use.
Port manipulation with the ATMega168 applies to the ATMega328 which is the UNO (and some others) chip.
At the bottom is a link to the 168/328 pin map. Note that the pins for the crystal (PB6&7), reset (PC6), RX and TX (serial to the USB chip, if you use serial then it's those 2) and all "taken" leaving you with 3 6 pin sets.
Thank you all for the suggestions. What I was trying to do with my code really was just to make it more compact. A for loop would not necessarily work with my code because of what it was intended to do.. It's very specific. When I typed everything out the right way, however, it all worked after some corrections.
Port manipulation lets you set multiple pins as close to simultaneous as it gets. XD
But looping through pins only takes microseconds and is simpler as you don't have to learn bit operations.