Voltage regulation or relay pulsation

Hello Arduino world. I am no good with coding so I am reaching out to you people. I use a slotcar racing lap counting system. It has an option for "refueling". The current scenario is that when your fuel bar reaches zero, then, any laps made will not count. Current voltage to the track is can vary between 12v up to 20v. If I where to put a buck converter in line, how can I add a code that would either pulse the relay to simulate the car is really out of gas or adding a buck converter to route main power through it to reduce power by "what ever I have the buck convertor set to"? Ideas, maybe with some sort of pictures would be great.... Thanks anyone, everyone!!!

@aronnp you posted this in Beginners Tutorials which is for posting tutorials for beginners. I have moved your post to a more appropriate place.

You could probably use PWM and when necessary mess with that signal by algorithm to simulate running or being outta gaz.

Please share a schematic of how the speed controller... is connected to the track... and to the power source and any other circuitry involved.

TIA

a7

A relay could simulate the "sputter" of a gas engine running-out of gas. That's a cool idea! And in real life racing the laps still count if you're out of gas and coasting across the finish line or into the pits...

A buck converter isn't necessary. A MOSFET driver can turn on & off like a relay and/or it can "pass-through" PWM from analogWrite() to slow-down a motor.

analogWrite() isn't true-analog but it lowers the average voltage to control the speed of a motor or to make an LED appear dim. (Your existing speed controller probably uses PWM.)

A slot car doesn't coast like a regular car that's run out of gas so slowing it down might make sense.

...So a MOSFET driver allows you more flexibility to experiment and do whatever you want in software.

This is a simple version of what I am using. This diagram is for 2 lanes where I use 3 or 4 lanes. And of the explanations of DVDdoug, the simulations of sputtering is more of what I am after. I do not want to have to add more and make things more complicated. And becasue I am not a programmer (coder) I do not know what the syntax would be to tell the relay assigned to the lane to when ( the fuel = 0, then "cycle" relay ???? 5 times a second...??? until it reaches back to the signal when it realizes they have "pitted" which is when the car stops over the sensor for X amount of time.

Please explain the function (s) of the UNO in the current setup, that is before you try adding the out-of-fuel thing.

Post the code that does that which you describe.

Where does an operator control (and how) the speed of her car?

a7