Wed Dec 21, 2016 4:43 pm
By far the easiest thing to do is forget the Pi, and use either an adjustable voltage regulator hooked up to a 12-18volt power source. Look for adjustable buck converter on ebay - I think you can get one for $2 USD on ebay. Put a resistor across the output to make sure there is some place for energy to go to avoid buildup. Maybe a 10k or so.
Alternatively and possible without ordering anything, you can connect a bunch of resistors in series all hooked up to a 12 volt power source. The to vary the voltage to your device, tap off the battery terminal for one lead, and use the connection between different resistors for different voltages between 0 and 12 volts for the other lead. You get as many different voltages as you put in resistors.
Robotics tips, hacks, book extras https://youtube.com/practicalrobotics