Slot car racing - - - just pure fun

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

dashboard

NR-flow

8 Likes

Damn, you've a nice job :smile:

2 Likes

One of the "perks" of being retired....:beach_umbrella: BUT still active !!! :running_man:

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 :smile:

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

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.

2 Likes

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

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.


ScreenShot040

Here's their Node-RED flow.

[{"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"}]
1 Like

[OT]Where did you get those buttons from?

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

AliExpress probably stock them as well.

1 Like

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

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.

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)

5 Likes