Pin states and control -export to mysql, xml or other format?

Hi there.

I will have about 70 inputs/outputs in the whole house.
In some rooms I will have traditional switches, in some rooms tablets with web control.
Each room will have a different tablet with the controls on the webpage specified for the room that the tablet will hang in.

What would be the easiest way (less code) to export data to php server and control two arduinos so then I can create webpage for the specific room?

I'm assuming that the two Arduinos are wearing ethernet shields, and are acting as clients. Is this a valid assumption?

If not, you need to define exactly where the Arduino is supposed to store the data, and how the data is to get there.

It it is, how/where to store the data is the responsibility of the php script on the server. All that the Arduino needs to do is make the proper GET or POST request.

Each Mega 2560 will have Ethernet shield on board.
Is there easy way to POST all 54 states of Mega 2560 in one POST request every 500 milsec?
Or would be better is server asks only for the pin states needed at the particular time?

I'd be more inclined to send states when they change or on request from the server. The server can request all of them when it starts - the Mega should do something at power up too - maybe just tell the server it's now available & the server can run its "tell me everything" routine for that Mega. Given this reduced traffic, you could do it with GET requests from the Mega if you prefer.

I'd also prefer to have the tablets not be tied to a room - have a page per room if you like, but let the tablet control any room - more convenient and handy when one of them dies/needs charging.

There will be a link on each webpage/tablet to control any room but each room will have a unique home page.
Tablets would be fixed on to the walls and the power will be provided.

Is there easy way to POST all 54 states of Mega 2560 in one POST request every 500 milsec?

The Ethernet shield will use at least 4 pins, so there will be at most 50 other pins to check. Checking the pins can be done every 500 milliseconds. POSTing the results every 1/2 second seems unlikely.

Either the Arduinos should be servers, and the PHP server should be making GET requests, as needed, to the Arduinos, or the Arduinos as clients should GET or POST only when there are changes that are interesting.

void setup() 
  pinMode(light1, OUTPUT); 
  pinMode(light2, OUTPUT);   
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  digitalWrite(light1, HIGH);
  digitalWrite(light2, HIGH);

void loop()
  int lightState1 = digitalRead(light1);
  if(lightState1 == LOW && lastlightState1 == HIGH)
    digitalWrite (light1, state1);
  lastlightState1 = lightState1; 
  delay(50);// a little debounce you may need to tweak

How to add POST to above code?

How to add POST to above code?

There is a LOT of stuff that needs to be added. Look at the Ethernet examples.