Use a voltmeter to determine exactly what is happening electrically. The software can be made to follow that, once we know exactly what it happening.

Cheers