Im trying to make an elevator like project, with a remote controller. It has two limit switches one at the top and one at the bottom.
Each time the controller is pressed the elevator should stop or go in the opposite direction it was going before stopping.
Im having trouble with the interrupts, it looks like the interrupts are getting triggered all at once, I tried separating the interrupt functions, defining debounce functions, doing the on off thing on the loop function, but can't get it to work properly. Does someone know what can I do? I'm doing it on an arduino nano every.
What I've found is that all the interrupts are getting triggered at the same time, each time I press the button on the remote and trigger the remote interrupt, the functions for the other interrupts are triggered too.
Please someone help me!
Can you please edit your opening post, select all code and click the </> button to apply code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code.
To start with, interrupts are not needed for this. Just reading the switches in loop() will do the job. Is there any reason why ou want to use interrupts?
Further, I suspect that bouncing of yourlimit switches / button causes the problem.
On a side note, for this project till now, you only need one pin and you can connect the limit switches / button to the same pin.
The problem is that i haven't even connected the limit switches, the pins are connected to a pull up resistor , im only using the remote controller on a pin, and when I action it, all the interrupts are dispatched.
I'll try again only with the loop function, the initial problem was that sometimes when I clicked the button on the controller, the loop function didn't read the input.
When this description match to your needs the following software modules are required:
input scan
derive values for motor control
run motor control
All these software modules can be realizied w/o using interrrupt business. Take a piece of paper and a pencil and design a flow diagram before to do a redesign of your sketch.
I tried programing a pic12f629, and im having the same issues.
I found that it works find before connecting 120AC to the board on the relays, I think i'm having interference issues, i'll try using relay modules that have optocouplers integrated to see if that fixes the problem.
Thanks everybody for your comments!