|
Re: sample limit switch code???
it would be much simpler to have the line of code that is controlling the motor also look at the limit switch on a digital input pin, instead of using interrupts
this is not really an interrupt application, because you are controlling the motor output on every loop of your code anyway, there is no reason to interrupt the loop when the switch closes - the victors and spikes dont respond that fast.
besides, contact switches bounce when they open and close - which means, instead of simply going from 0 to 1, they go 0000111110011011010101111111111 - so for every switch closure you will see maybe 20 to 100 interrupts within several milliseconds.
|