Regulate Relay Output

Hello Arduino Community,

At the moment I am doing a project at my school and I'm so glad to use an Arduino Uno.
Just a quick overlook over the project:

We are running a miniature train that's driving on a straight railtrack. At each end of the railtrack there is a photoelectric sensor. When the train drives through one of the sensors, it drives in the opposite direction, because of relays. The whole thing is supported by a solar cell.
The whole project is made to demonstrate the younger students the power of solar energy.

The problem is now, that our solar cell is providing so much power, when the maximum amount of light shines on it, that the train is too fast. At first we wanted to regulate it by just putting in some resistors. Thus when the sun is not shining at its maximum the resistor hinders the train to move.

My idea was to give the relay a maximum voltage output limit, but I haven't found other parameters than 'HIGH' or 'LOW'.
Is there an other way to regulate the maximum allowed voltage output of a relay, than by resistors or are there other parameter values?

Thanks in advance :slight_smile:


Tl;Dr: How can I regulate the maximum voltage output of a relay?

Relays do not output voltage, all they are is a magnetically controlled switch that can touch two pieces of metal together or pull them apart.

What you probably want is a buck-boost regulator. They're dirt cheap of ebay if you don't mind waiting for the slow boat from China, though if you need one faster I'm sure you could find an EU retailer to ship one.

The key words to search for are "buck boost". A buck regulator can only reduce voltage, a boost regulator can only increase voltage, but a buck-boost regulator can do both. As long as there's enough sunlight, it will hold a constant voltage even if it gets too strong.

Maybe use a H-bridge (e.g. L298 or a fet based one) and PWM to control speed and direction?

Can you put a roller shade over part of the solar panel to Really demonstrate the sun’s power?
Or some miniblinds, open and close them as needed.

Hello,

Sorry for the late answer. Apparently it didn't send the one I wrote on my phone. However I want to thank anyone of you for your suggestions

@Jiggy-Ninja I liked your way best, so I took your idea and it works perfectly. Thank you

@sterretje I also want to thank you, too. Your option looks good too, but it is over my capacities

@CrossRoads I like your idea but no, that wasn't possible. Though we demonstrate the power of the sun witht he velocity of our little tschoo-tschoo train :slight_smile: