Hi all, i’m using several GPIO’s in Arduino mega due to large number of IO i’m using array to declare pins and enable it’s output using for-loop, code for same mentioned below.
But something unpredictable is happening whenever i change declared pin no. in array either it does not enable all the declared pin or enable all pins irrespective of defined one. I don’t understand why this happens at first it was working perfectly but as soon i modify pin numbers inside array it start working improperly. Please help what could be the issue whether i have to define size of array or there is something else??
Those could all be byte as the values are <= 255, no need for them to be int (-32768 to 32767), or unsigned int (0 to 65535). Save a byte of memory on each one, might come in handy one day.
One thing more i noted when i delete all array’s and rewrite them it again start working properly and when again i make changes to pins it start behaving abnormally!!! I don’t understand why this is happening…
digitalWrite(Part1Relays[1], LOW); // where 0 to 7 can be used
:
:
digitalWrite(Part1Relays[1], HIGH);
As mentioned earlier i'm using Arduino pins using an array and calling several function based on required operations of pins but as whenever i edit or make changes in array declaration like changing pin nos. it start behaving improperly. what could be the reason?