This is what i'm thinking at the moment, but as I said, analogue electronics isnt my strong point so I could be way off track.

Opamp and schmitt trigger configured for threshold detection: