# Controlling model train

**URL:** https://discourse.nodered.org/t/controlling-model-train/30276
**Category:** Share Your Projects
**Created:** [17 July 2020 19:13 UTC](https://discourse.nodered.org/t/controlling-model-train/30276 "2020-07-17T19:13:40Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)
#### Post date: [18 July 2020 09:31 UTC](https://discourse.nodered.org/t/controlling-model-train/30276/4 "2020-07-18T09:31:35Z")

</div>

I did a similar thing with a group of students a few years ago.  
We used PIC microcontrollers talking to signals and points using a CAN bus.  
We also used PWM to control the speed and direction of the train.

If I had the time to "do it again today" I think I'd use Wemos D1s (ESP8266) and Node-RED as I could control everything via WiFi using MQTT.

I like your idea of using SVG - I'm sure Bart @BartButenaers will think it's a great application for SVG.

Note:  
You can write finite state machines using JavaScript (as well as using the FSM nodes).

Here's a link to a slot racing car project I did with my IoT students.

> [@Slot car racing - - - just pure fun](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782):
>
> I make no excuse at all - this is just pure fun. My students will love it !!!! I've just bought a slot car racing set from a local charity shop and have connected it to a WeMos D1 Mini on a breadboard driven from Node-RED via MQTT. On the breadboard is a PCA9685 (16-channel, 12-bit PWM module). It took some time sorting out the best PWM frequency and range settings, but eventually settled on 1500Hz with a range also of 1500. The car goes from a slow "creep" to just below "max speed", as at …

---

_[View the full topic](https://discourse.nodered.org/t/controlling-model-train/30276)._
