dual swing gate controller newbie reqesting advice and guidance

Hi guys i'm after some guidance with my first project.
After a repeat failure of the control board in my gate opener ,i decided i could do better myself.
any way the hardware is completed i believe my sketch is 90% complete.
and i have checked individual parts of the code as well
but if anyone would like to have a look over my sketch and point out any troubles i might have it would be greatly appreciated
hardware is as follows

-arduino mega r3

-bts7960b motor controller x2
each requires +5 volts
ground
2x enable pins pulled high
2 x pwmon forward and reverse
2 wires for current sensing forward and reverse

-4 reed switches
2 gates each with open and close switches = 4

2 inputs debounced through ic pulled low when active
1st for pedestrian access
2nd for vehicle access

MC14490 DIP16 Hex Debouncer IC

  • 7ah 12 volt batterys in series

  • 5 volt regulator

-12 volt regulator

on the software side i plan to use 2 interrupts for the two access requests while the arduino carries out its other tasks i have in plan for it later on like controlling lighting when its dark sensing if a vehicle is parked in the drive way triggering a doorbell when the gate button is pressed etc

gate_logic.ino (923 Bytes)

gate_open.ino (1.08 KB)

gate_switches.ino (607 Bytes)

gateIs.ino (647 Bytes)

light_fade.ino (860 Bytes)

lm902gateopener.ino (2.32 KB)

lock_open.ino (296 Bytes)

motor_enable.ino (744 Bytes)

motor_openClose.ino (1.04 KB)

pin_numbers.ino (972 Bytes)

sensor_light.ino (521 Bytes)

That is an awful lot of stuff to look at.

Does it do what you want ?

If not, describe its shortcomings and tell us where in the code that issue is handled.

...R

i am just at the benchtesting stage with modified code to run only one gate actuator atm

i guess my main question is am i going about it the right way by using interrupts to trigger an open sequence so i dont have to continuously poll the inputs?

and if so what constitutes a "short" isr?

Sorry if I was not clear, but I am just too lazy to download and read all those files. I would prefer to give the time to assisting other Threads. It would make things easier if you put all your .ino files in a .zip file so I only have to download one file. But even then a narrative that explains how the parts fit together would be a big help.

Continuous polling is perfectly reasonable and is generally easier to implement than interrupts. The Arduino will be doing 16 million instructions per second anyway so you might as well use them for polling.

Interrupts are essential if you want to detect a very short-lived event or events that happen at high frequency. That is unlikely to be the case with gates.

An ISR should be a short as possible and certainly not longer than about 100 µsecs. It should not contain any Serial.print() statements.

If you point out which file has your ISR code I will look at it.

...R