Post your code in tags </>.
Maybe some debug (Serial.println) statements would help show what it's doing.