Please provide us with the model # XXXXX machine and are you saying that it will agitate for a while then quits and the timer advances or the timer does not advance. Does it spin O.K ?
The most likely place to start is the lid switch . possibly the part on the lid that goes down and hits the switch is broken or more likely the lid switch itself is bad. Here's the part number(NNN) NNN-NNNNand cost is about $ 14.00. You should hear it " click " when you open and close the lid. Get back if you need more help.