Does anyone know of a arduino mega compatible mechanical lever arm switch like the one Ive attached below
but one that can travel in two directions. I can`t find a switch where the arm points vertically out. I need it for an application that will eithier increment or decrement my counter when my model train passes through when it goes in a certain direction(forward or backward)
I'd look for something contactless, such as two break beam sensors next to one another. Which one triggers first tells you which direction your train goes. Saves you getting lines on the side of your trains where the switch touches it. Mind that you get to see all the gaps between cars as well, account for that in software: beam must be unbroken for a minimum amount of time or the next break is not another train.
wvmarle:
Mind that you get to see all the gaps between cars as well, account for that in software: beam must be unbroken for a minimum amount of time or the next break is not another train.
A common solution for that is to make sure that the beams are not perpendicular to the track.