Near where I used to live there used to be tracks with a notch on them - pressing a coin onto it used to make the boom gates go down and stop the traffic. I did that a few times. I wonder how confused the people in the cars were. Boom gates down, lights flashing, no train coming.
In the US, the crossing signals are controlled by an electric circuit in one rail which is closed to the other rail by the metal train axles. At pretty much any railroad crossing in North America the crossing circuit is seperated from the rest of the track by insulated joints (usually painted in a bright color so crews can find them. By placing a metal object on the tracks so that it touches both rails, the gates will come down as long as you're within the crossing circuit area. If you do it outside the crossing circuit area, the train signals will indicate to other trains that there is a train where you are and will thus go red, sometimes for many miles.
That being said, tampering with railroad equipment is a felony offense, and has been for over 150 years.