I will make an arduino program for the railway latch.
but I have difficulties
I am still confused with the program for its ultrasonic sensors
when the portal closes, but the train has not passed, I'm worried the portal will reopen
how to program the ultrasonic sensors so that when the bar closes, but the train has not passed, the bar is still closing
and will reopen when the train has already passed through the ultrasonic sensor and the ultrasonic sensor does not detect any train in front of the sensor
It is difficult to understand your explanation, but it may be that you want to detect when a train becomes detected rather than when a train is detected.
If you can give a better explanation then it will be easier to provide help.
God, I hope he/she is talking about model trains and not ones carrying PEOPLE ![]()
An ultrasonic sensor is not likely to be the best sensor to be using to detect a moving train.
amiraenef:
I am still confused with the program for its ultrasonic sensors
when the portal closes, but the train has not passed, I'm worried the portal will reopen
how to program the ultrasonic sensors so that when the bar closes, but the train has not passed, the bar is still closing
and will reopen when the train has already passed through the ultrasonic sensor and the ultrasonic sensor does not detect any train in front of the sensor
It would help tremendously to break this conglomeration into discrete sentences that: express single thoughts; begin with capital letters; end with periods ( . ); include at least one space between sentences.
If you cannot express your idea clearly how is anyone to divine your meaning?
As well as what @dougp has said it would help if you explain what you mean by "railway latch" and "portal".
I am reasonably familiar with railway modelling and I have not heard those terms used.
A diagram of what you are working with would be a big help.
...R
When answering a question please:
Read the question carefully
Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
The sensor detect an presence of an event and then returns a value as long as there is an object - same as SONAR detect an object then returning "ping".
Call that 'object detected" state.
Next job is to detect an absence of an object - no "ping".
Basically like this
while( object not present ) - wait for an object
while ( object present ) - wait for an absence of object
and when you get this working you can tackle non blocking code version.
232:
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
To whom is this addressed?
I did not insult anyone, and I don't think anyone else did either.
...R
I just don't think an ultrasonic sensor will work here. Is it beside the track, looking down the track or above the track? I would use 2 break beam sensors at a distance from either side of the crossing that would allow time for the gate to close before the train got there. The break beam sensors would look diagonally across the track so they would not see gaps between cars, and a third proximity type sensor to detect a train IN the crossing.
outsider:
I would use 2 break beam sensors
I have found that a Light Dependent Resistor (LDR) placed between the sleepers is a cheap, simple and effective way to identify the existence of a train. Judicious use of timing can deal with gaps between wagons.
...R