apartmentjilo.blogg.se

Headon train sketch
Headon train sketch








headon train sketch

When you will connect LEDs of the signals, you will probably mix up the wires.

Headon train sketch code#

Also, sketches code does not exceed 200 lines for a COMM unit and 100 lines for Local units. If I tried to use only one board, I would also already have problems with free pins, since there are already more wires for the peripherals than pins on one Arduino NANO (UNO). Note how much easier and more logical it is to connect devices to multiple Arduino boards. That's why I created a separate block, which is always located at the very end of the void loop. Since the code in the microcontroller is executed sequentially from top to bottom, it is possible to incorrect switch relays before the end of the general algorithms. This is also a rule of the URB project - in the future, parsing and other code (for example, algorithms from sensors) will make changes to the state of the system state variables. You can immediately add the relay switching code in the parsing block, but I put this code in a separate block.

headon train sketch

You may have noticed the redundancy of the sketch code. The rest of the circuit does not need to be changed or reprogrammed.

headon train sketch

You only need to change the sketch of the Local 2 unit and connect the relay to it. And here's the first advantage of connecting several Arduino boards via a common bus. In this experiment, we control two turnouts with one button (in fact, there are many ways to create switching algorithms, including individually switching each the turnout from the app).










Headon train sketch