Arduino to Arduino Port Reading

So here is the deal

i am making an aplication to measure cycle time of the machine states in a manufacturing process..

my arduino will do a bunch of stuff and will have portC as input always reading between 0,1,2,3,4,5.. machine states...

....

to simulate my code i have another arduino just jumping from state 0,1,2,3,4 randomly....

Void loop{

machine_state=PINA;


if(last_state==machine_state)//Scan
{ 
 // do nothing just wait until a machine change in state 
}
else{
  
  

 // Serial.println("");
 // Serial.println(machine_state);
// difaverage();
  //***just enter once
if (machine_state==0)
{ 

Serial.println(""); 
  Serial.println("state 1"); 
 last_state=machine_state;
  
}
if (machine_state==2)//Frame clamped
{
   Serial.println("");
   Serial.println("state 2"); 
   last_state=machine_state;
   
}
if (machine_state==4)//Frame released
{
   Serial.println("");
   Serial.println("state 3");  
  last_state=machine_state;
}

if (machine_state==6)//Call button
{
   Serial.println("");
   Serial.println("state 4");   
   last_state=machine_state;
}


if (machine_state==8)//Call button
{
   Serial.println("");
   Serial.println("state 5"); 
  last_state=machine_state; 
}

last_state=machine_state;
}


}//end of loop

i have problems when i go from state 2(010) to state 3(100)... it goes to state 4(110)(skipping state 3).. the controller is read the bit transition... i have added some delays but i could not get it to work...

any tips?

If you are using port C, then why are you reading port A?

machine_state=PINA;

[quote author=Tom Carpenter link=topic=116189.msg874619#msg874619 date=1343418917] If you are using port C, then why are you reading port A?

machine_state=PINA;

[/quote]

Sorry, i am reading port A on a MEGA

if(machineState & 0x01){
  //do stuff
}
if(machineState & 0x02){
  // do stuff
}
if(machineState & 0x04){
  // do stuff
}
if(machineState & 0x08){
  // do stuff
}

etc.

http://arduino.cc/en/Reference/BitwiseAnd

mmm i tried but it does not seems to work.. any other ideas?

i guess i will do it similar to a parallel port, with a clock signal ...