Hi guys. I want to make my code a bit more robust and light because I have a little bit of trouble with the amount of data the ethernet shield can handle. If I am near 16kb of code, it crashes, although the arduino has 32kb. Anyway... To the point

I want to substitute the following piece of code and make a "for loop" for the pins 2-9 but I don't know how to make it read the ("on1"), ("off1), with 1 being an int i.

Thanks for your answer The on1, on2, on3 etc are address bar queries for switches so that's what I m trying to read. I m not sure how to use sprintf() to achieve that (noob alert ). Can you make a proper synstax on this if(readString.indexOf("on"i) >0) with i being the int? Thanks again

Do a search on Port Manipulation. With an UNO you have 6 pins open on 2 ports and 4 on the other by default. You could pack your data bits into 2 ports and get your 8 bits out in just 2 writes. With a MEGA I am guessing you'd have a full port open to use, 1 write would do.