I am a mechanical engineer using an ATXMEGA128 A1U to control a system with a servo motor. This motor will displace an object attached to an encoder to provide position feedback. On either side of the travel range are limit switches.
Since this is my first time designing something like this and only have about 4 months experience programming AVRs, I'd like to ask the community in general about best practices when using limit switches.
I want the limit switches to stop what it's doing, turn off the motor, and turn on a red LED. I would then press a button to reset the system.
I think I need to connect the output of the limit switch to a pin and route it to the event system. Meanwhile, there is an ISR that is running which is driving the servo motor.
Any guidance would be appreciated. I will also appreciate suggested topics to study.