It's multiuser app allow players interaction with other individuals in collborate control a railway.
Another way to use it feature mode for single player is to switch controls between independent railway segments.
This App is participate in the Designed for Families program on Google Play. You can share this app from Google Play with up to 5 family members using Google Play Family Library.
This application has the same features as Junior Lite +
- Version 5.0 now supports Inertia Mode Drive
- Multiplayer control from two Android devices
- Manage 4 turnouts
- Button for set turnouts to default position
- Interactive button AWS (Feedback mode)
- Support Extended Reverse Loop (Protocol 2.3)
- Native support extended automate and interlocking moving trains
Play games together – unique feature of the URB project
Arduino Train Junior PRO
Arduino Train DUO
The sketch in this example is a modified version of the sketch for beginners, but It immediately allows you manage separate rail tracks. If you want to add a second player you need another Bluetooth module HC-06. The scheme is almost the same as the first example for begginers.Double sketch
How use Bluetooth
The reason of using Bluetooth in URB project described on the Railworks page. According to reviews of modellers using my applications, there is often a confusing situation with the connection of several Bluetooth modules. The problem is not in the connection itself, it works very reliably, but in naming matching the multitude of devices paired with the phone with Bluetooth. Therefore, initially in my applications, the MAC-address of the connected device is displayed. In addition, on start each video about my applications, it begins with a video instruction on pairing Bluetooth module HC-06.
Since the project can use several Android devices, here I post the step-by-step instructions on how to connect in this situation.
Pairing a new HC-06
Connect HC-06 to the App
If you try to connect to the HC-06 module that is turned off or already connected to another phone, you will receive an error message. So just repeat the procedure with the another module.
The effect of connecting a USB cable together a Serial RX TX pins
In all the previous examples, I used a software serial port that can be connected to any GPIO pins of Arduino. It's solution add the independence of the Bluetooth channel from the USB. Thus it was possible without disabling Bluetooth upload the sketch from your computer via USB to Arduino, which was very convenient for experiments with sketches reprogramming. But in this example, we need two control channels, so if you forget to disconnect the second Bluetooth module from the Arduino, then when you upload the sketch from the computer, you may will get an error or endless uploading in to Arduino.
When you upload the sketch into Arduino via USB, the data from the computer goes to the same pins RX and TX as are used by second Bluetooth module. Therefore, if you upload the sketch, unplug SECOND Bluetooth module wires RXD and TXD.
I'll tell you a little secret: Arduino UNO and Arduino NANO use the same microcontroller Atmega 328, which means that there is no difference between them, even at the output GPIO pins. That is, they are exactly the same, but Arduino NANO board is smaller size.
The power divided into two branches, one for moving trains, the second for electronics and devices on the layout. Thus, with short circuits on rails and other troubles with trains, the layout control will not be affected.
To turn 5V power on your Arduino, use any charger for modern smartphones with a USB connector. The current of such chargers should be about 1 A. For the movement of trains, you can use the transformer you already have from the starter set or any DC power supply with 12V. Please note that the output current also should be about 1 A or more.
It is convenient to carry out the connection of wires between the power supply unit and the motor-driver through the power plug-screw terminals.
This experiment consists of two independent loops (green and purple) and the one transition (white) line, connecting the loops with each other. My project works as DC mode, so for this track plan I accepted the condition that only when the turnout A have position to branch, then White Line the correspondences with Green Loop. Otherwise, the rail voltage on the White Line is transmitted from the Purple Loop. Using this simple algorythm you can move trains from one independent loop to another via White Line interconnection.
In this example and hereinafter, I will use the URB units, but you can use your Arduino shields or collect electronic circuits on the breadboard.
I use here two URB units interconnected by bus I2C and power supply wires of logic. This allows us to simplify and standardize sketches, provide a convenient connection to railway peripherals (switch machines, signals, etc.), as well as dramatically reduce the number and length of wires. Accordingly, for two URB units, two sketches are required.
Wiring diagram consist two relays for transferring power to the White Line. In a sketch, these relays are controlled by one command and, accordingly, only one pin is needed on Arduino.
In the sketch code, the position of the Turnout A determines the state of the Boolean variable, which then switches the Interconnection Relay. I apply the following rule: if the turnout has a direct position, then the value of the variable "1" or TRUE, if the direction of the junction to the branch then the variable "0" or FALSE. For the active / passive the path state, respectively: 1 (TRUE) / 0 (FALSE).
By using these variables, the COMM URB unit remembers the state of all lines and paths, and you can use comparison operators to program the logic of the behavior of signals, relays and other things.
You can use much more complex logical constructions and dependencies, for example for automatic train movement on a schedule or use scripts. The task of this example is to show you these possibilities.
The dependence of the White Line on the position of the Turnout A
Electric Switch Machines
Into the URB unit you can connect any types point-motors for switching turnouts – servo, electromagnetic and having a stepper motor. Features of the use of different types, see the section of the URB project. But in this experiment I will use the classic electromagnetic motor. The sketch is written for this type of device. So you need a separate power source with a voltage of 14 to 17 volts for switching these point-motors. Therefore, you need have a separate 16V DC output on your power supply terminal block of or have a separate source of this voltage.
You can change the type of drive, as well as use different voltage converters by changing the sketches accordingly. A detailed description of such changes is available to the members of the URB Club.
Explanation of the experiment
In this experiment, data from COMM URB to LOCAL URB is transmitted via bus I2C. Together with the power wires, this tire is called URB BUS. You can send commands via the I2C bus to any peripherals (point-motors, servos, signals, remote motor-drivers and etc.) connected to any URB on the layout. Thus, you can build a short topology wired connections on the layout, which greatly simplifies the electrical circuit of the control system.
Compare classic and URB topology
Pay attention to the behavior of the built-in LED in Arduino NANO on the Local URB unit when you switching the Turnout A.
In the comments in the sketch there is a description of the variables and the purpose of the commands being executed. Ways fitted sketches to your track-plan or create your own sketches look on official site Arduino, ArduinoHUB or my YouTube channel. A detailed guide on sketches for the project is available for the members of the URB club.
Insulated rail joiners
Rail joiners are small clips used to join two sections of track mechanically. They come in metal (nickel silver) which also connects the rails electrically, and plastic which are insulated to isolate the two sections of track electrically.
A Relay is an electrically operated switch. Many relays use an electromagnet to mechanically operate the switch and provide electrical isolation between two circuits.
2 URB units
Universal Railway Bus unit is first and foremost a convenient and reliable connector, replacing the breadbord and a bunch of wires. A more important feature of URB is the integration of several blocks into a chain, and on this basis the construction of any electronics for layout and control. In other words, it is the Universal Controller for all electronics railway modeling.
The motor switching of turnouts in railway modeling gives a lot of convenience opportunities and gives rise to several problems. For example, the position of the junction can be uniquely associated with traffic light signals and, as a result, you will get a ready signal system. But at the same time, most of the modellers make bulky and complex panels, and their upgrade will very complicity. This problem is further aggravated by the fact that the position of the arrows is not always known after the layout is turned on.
All this was taken into account in the development of this project by changing the sketches of a particular URB, you can program any logic of the behavior of the signals. Also in the application there is a button DEFAULT, which sets junction to the position assigned user, the same happens when the layout is initialized when the power is turned on. Since there may be more than one player in the project, this button also helps to synchronize the position of the lines during the game. Without using extended feedback (only at Arduino Train DUO), the DEFAULT POSITION button is very useful.
To implement this function, there is no need to change the connections or add new devices – just add a few lines of code to the sketches of the URB units. In this experiment, such lines are added to the previous example, extending its functionality. After updating the sketches, when you will click on the icon DEFAULT POSITION on the app, you immediately set all the arrows in the forward direction and the built-in LED on the Arduino NANO of the Local URB lights up.
Set to default position is the standard code executed when the layout is turned on or the Bluetooth connection is initialized and is included in the code for all the following examples.
The URB project and Arduino Train applications native support all kinds of sensors for Arduino. In this experiment, it is shown how to make the automatic stop of the train before deadlock. Such a situation may arise for example if you do not see the end of the track in the tunnel. In the video, such a system works with a Hall sensor, but you can replace it with an Infrared or any other type of sensor (more information about sensors see on Railworks page).
For each driver in the Junior PRO application, the alarm and reset of the AWS button work independently. This button can also be used for more advanced systems, such as Interlocking.
Arduino Train Junior PRO
Arduino Train DUO
The CUSTOM TOGGLE is a universal two state button has functionality which you can by himself define in the sketch. With this button you can manage the activation of sensors, various moving mechanisms and lights on your layout. In the video you can see an example of remote control of a railway crossing.
Arduino Train Junior PRO
Arduino Train DUO
Let's do fun to have control under many trains. Above you will see a railroad plan that can operate in two modes.
The first is the usual control, where blocks 1, 2 and 3 are controlled by Driver B from the Pro or DUO applications, and the orange section containing the station and controlled by Driver A.
The second is a combined control method, where blocks 1, 2 and 3 work as a single automatic interlocking system, and the orange section is still managed by you.
Change of control modes is performed in this experiment using the CUSTOM button. The activated button means the working of automatic interlocking control in railblocks.
In this experiment, for simplicity, the direction of movement in automatic mode is one-way. Perhaps in the following examples more complex scenarios will be presented, but so far I am limited by the number of sensors I have. A feature of this experiment is the control of each Block by a separate channel of the motor-driver. This allows you to implement smooth stop and start algorithms before signals in automatic mode.
Here is my plan for managing the finished system – you let the train go from the station to the first automatic section, if the signal Block 1 is GREEN. When a locomotive arrived to the start of Block 1, the automatic control takes control and leads the train to signal Block 2. If it is green, then the movement continues without stopping, otherwise the train gently stops before signal Block 2. And so on, as in a conventional interlocking system.
The exit of the train from the interlocking system (block 3 – signal Block 4) will be permitted by you if you set turnouts on the station so that one of any three station signals is green. You can apply any other scenario to get out of interlocking, since the URB project is designed to implement your ideas. The long section D in front of the station allows you to make maneuvers by trains on the station, while the rest of the trains are blocked on Blocks 1, 2 and 3. That is, if there are open blocks on the automatic control section the train will continue to move to next open block. This is one example of the simultaneous movement of many trains in a scenario. That is, the game consists in manipulating the trains at the station and catching them at the entrance to the manual control section, this is very different from the boring control of one train.
You can use any of my applications for this game, only the Arduino Train Junior Light application has a limit on the numbers of turnouts and players.
Arduino Train Junior PRO
Arduino Train DUO
This starter example contains the simplest code possible. Therefore, it not polls sensors via I2C bus, all motor-drivers are also connected only to the COMM unit. Also, the possibility of a smooth start of the train in automatic mode is not realized. The sketches below also suggest the use of infrared sensors of my design, which are guaranteed to give the correct signal. It also simplifies the code, however you can easily modify it for any other sensor designs.
Total for this experiment, three URB units are needed. All connections and algorithms are similar to the regular code of the URB project. Sketches contain a code for point-motors on servos. You can also change it for electromagnetic switch-machines by changing the connection scheme of Local URB units.
The site will gradually appear new examples adapted to your requests. If you have a desire to see your track plan on the site, then send me message.
Any sketches or circuits presented on this site is not a dogma. For example, you can see that the wiring between the Arduino and the Motor-driver is different in these examples. That is, you can always change your project just by modificate the sketches.
Project documentation is available to advanced project participants in the URB Club.
As you see, that asembling of the circuit by connection wires over the breadboard is a very inconvenient task. As the circuit becomes more complicated and the components added, problems are added with the correctness and reliability of connecting the wires and blocks. Therefore, I suggest you make a free URB unit that solves not only these problems but also adds new tremendous functions. You can collect a similar scheme on the breadboard, but URB is much more convenient!
Dual control can be applied in other games. The scheme given at the beginning of this page for Arduino and the sketch to it may will also apply to any other similar systems, for example, to toys like Electric Loop Road Racing.
Racing small cars from two smartphones is a very fun activity!