# Slot car racing - - - just pure fun

**URL:** <https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782>\
**Category:** Share Your Projects\
**Created:** [9 March 2019 16:32 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782 "2019-03-09T16:32:45Z")\
**Posts on this page:** 13\
**Page:** 1

<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:** [9 March 2019 16:32 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/1 "2019-03-09T16:32:45Z")

</div>

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 "max speed" the car spins off the track.  
I'm sure my students will enjoy seeing the car spin-off the track - but that's not my primary objective (hiss, boo I can hear them say).

For those of you with sharp eyes - yes (for clarity) I've only wired-up the red car to channel-15.  
The yellow car will connect to channel-14 on the PCA9685 via a 2N3053 power transistor.

![slot_racing](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/fb24626b4abb13b3f55c6acab2a7d68d2b74cf0e.jpeg)

![dashboard](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7d2b1b6919ad638ecf09a4b1b22472fb8af5e26d.png)

![NR-flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/052d9226b342364a6f9df54f65b8102f3e430d0e.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [9 March 2019 16:38 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/2 "2019-03-09T16:38:50Z")

</div>

Damn, you've a nice job 😄

---

<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:** [9 March 2019 16:39 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/3 "2019-03-09T16:39:40Z")

</div>

One of the "perks" of being retired....🏖 BUT still active !!! 🏃‍♂️

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [9 March 2019 16:54 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/4 "2019-03-09T16:54:06Z")

</div>

I'm looking forward more and more to when I can retire - sadly still some way off as yet.

Though I'd also be sad to give up my day-job. Just too much to do in life 😄

---

<div class="post-metadata">

**Author:** ![machadotiago](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/machadotiago/32/23776_2.png) [@machadotiago](https://discourse.nodered.org/u/machadotiago)\
**Post date:** [9 March 2019 22:16 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/5 "2019-03-09T22:16:05Z")

</div>

> [@dynamicdave](#):
>
> the car spins off the track.

Oh, come on, you should not say such a thing without posting a video 🤣 we really want to see that.

---

<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:** [10 March 2019 09:20 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/6 "2019-03-10T09:20:16Z")

</div>

Sorry - I've dismantled the racing set ready to take it to school.  
I'm sure one of my students will happily video the car's track handling performance later this week.

---

<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:** [13 March 2019 19:07 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/8 "2019-03-13T19:07:49Z")

</div>

A short video of the yellow racing car going at various speeds.  
You may notice that at no time did the car leave the track!!!

[https://photos.google.com/photo/AF1QipO3usbu\_pGQ9B\_k8wJDtqh6YlqS70pGMkHvDIE](https://photos.google.com/photo/AF1QipO3usbu_pGQ9B_k8wJDtqh6YlqS70pGMkHvDIE)

---

<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:** [20 March 2019 08:10 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/9 "2019-03-20T08:10:56Z")

</div>

A couple of my students have added a couple of touch-sensitive buttons to a Wemos device (running ESP Easy) to control the yellow racing car.  
The button on the right increases the speed (in increments of 25), the one on the left slows it down.

 ![touch_buttons](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8667f425ba7836c0e9b5c66c4fddf3965fc1ed41.jpeg)  
 ![ScreenShot040](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0603601b2faf6fe20e54929e58dd855d3aa5042b.png)

Here's their Node-RED flow.

```auto
[{"id":"15ecc533.d36b0b","type":"ui_slider","z":"48389844.d0f188","name":"","label":"Red car","tooltip":"","group":"66aa58d4.c1cd1","order":1,"width":"10","height":"1","passthru":true,"outs":"all","topic":"","min":"750","max":"1300","step":"25","x":200,"y":120,"wires":[["185d5fe4.00fa9"]]},{"id":"185d5fe4.00fa9","type":"mqtt out","z":"48389844.d0f188","name":"","topic":"node90/cmd/PCAPWM/15","qos":"","retain":"","broker":"5ef29389.24415c","x":440,"y":120,"wires":[]},{"id":"95d1115d.4de65","type":"ui_slider","z":"48389844.d0f188","name":"","label":"Yellow car","tooltip":"","group":"f1af5ce5.753738","order":1,"width":"10","height":"1","passthru":true,"outs":"end","topic":"","min":"900","max":"1300","step":"25","x":210,"y":180,"wires":[["ce23cd27.fe1048"]]},{"id":"ce23cd27.fe1048","type":"mqtt out","z":"48389844.d0f188","name":"","topic":"node90/cmd/PCAPWM/14","qos":"","retain":"","broker":"5ef29389.24415c","x":440,"y":180,"wires":[]},{"id":"8e57c6a8.331ed8","type":"mqtt in","z":"48389844.d0f188","name":"","topic":"/node34/fast/#","qos":"2","datatype":"auto","broker":"5ef29389.24415c","x":220,"y":280,"wires":[["5f8a027.15a767c"]]},{"id":"3350100d.8a3328","type":"debug","z":"48389844.d0f188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":280,"wires":[]},{"id":"deb0d866.d49588","type":"mqtt in","z":"48389844.d0f188","name":"","topic":"/node34/slow/#","qos":"2","datatype":"auto","broker":"5ef29389.24415c","x":220,"y":340,"wires":[["4469c919.2b197"]]},{"id":"add3dc3a.3e454","type":"debug","z":"48389844.d0f188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":610,"y":340,"wires":[]},{"id":"ea7e0a07.a23b78","type":"inject","z":"48389844.d0f188","name":"","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":210,"y":420,"wires":[["e96b0aa8.6c9e4"]]},{"id":"e96b0aa8.6c9e4","type":"function","z":"48389844.d0f188","name":"Initial conditions","func":"flow.set(\"speed\", 900);\n","outputs":0,"noerr":0,"x":440,"y":420,"wires":[]},{"id":"5f8a027.15a767c","type":"function","z":"48389844.d0f188","name":"Fast","func":"var speed = flow.get(\"speed\");\n\nif (speed < 1300)\n{\n speed = speed + 25;\n flow.set(\"speed\", speed);\n msg.payload = speed;\n return msg;\n}","outputs":1,"noerr":0,"x":410,"y":280,"wires":[["ce23cd27.fe1048","3350100d.8a3328"]]},{"id":"4469c919.2b197","type":"function","z":"48389844.d0f188","name":"Slow","func":"var speed = flow.get(\"speed\");\n\nif (speed > 900)\n{\n speed = speed - 25;\n flow.set(\"speed\", speed);\n msg.payload = speed;\n return msg;\n}","outputs":1,"noerr":0,"x":410,"y":340,"wires":[["ce23cd27.fe1048","add3dc3a.3e454"]]},{"id":"66aa58d4.c1cd1","type":"ui_group","z":"","name":"Red","tab":"74b698f5.19001","order":1,"disp":true,"width":"10","collapse":false},{"id":"5ef29389.24415c","type":"mqtt-broker","z":"","name":"","broker":"192.168.1.138","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"f1af5ce5.753738","type":"ui_group","z":"","name":"Yellow","tab":"74b698f5.19001","order":2,"disp":true,"width":"10","collapse":false},{"id":"74b698f5.19001","type":"ui_tab","z":"","name":"Slot Car Racing","icon":"dashboard"}]

```

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [20 March 2019 09:47 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/10 "2019-03-20T09:47:17Z")

</div>

[OT]Where did you get those buttons from?

---

<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:** [20 March 2019 10:04 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/11 "2019-03-20T10:04:30Z")

</div>

> **[US$5.16 10pcs TTP223B Digital Touch Sensor Capacitive Touch Switch...](https://www.banggood.com/10pcs-TTP223B-Digital-Touch-Sensor-Capacitive-Touch-Switch-Module-For-Arduino-p-1162258.html?rmmds=myorder&cur_warehouse=CN)**
>
> Online Shopping at Banggood.com！

GBP 3.96 for a pack of ten, so less than 40p each.

AliExpress probably stock them as well.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [20 March 2019 13:55 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/12 "2019-03-20T13:55:50Z")

</div>

Ta 🙂 Found some equivalents on Amazon (£6 for ten delivered tomorrow) so decided to splash out on the extra £2:04

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 March 2019 15:44 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/13 "2019-03-20T15:44:21Z")

</div>

Ah, nice find. I can think of some uses for these. Family friendly on/off switches for remote controlled lights for one, they will add nicely to my ESP8266 sensor platforms.

---

<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:** [20 March 2019 16:33 UTC](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782/14 "2019-03-20T16:33:38Z")

</div>

OMG - I must stop visiting this charity as I couldn't resist buying this Hare and Tortoise game today.  
Never seen this game before in my life.  
It says on the box for 6+ year-olds with knowledge of PWM (ha, ha, ha)

 ![how_cool_is_this](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/0e59cfa4c1260123c1fe90a5148285f6eb5f7b73.jpeg)
