@Mig192: You appear to have three separate, but not necessarily unrelated, problems: (1) provide power to a microcontroller; (2) provide capability of sensing, using bit-input ports on the microcontroller, signals from external equipment, said signals being either off (0 V DC) or on (22 V to 28 V DC); and (3) provide a means, using bit-output ports on the microcontroller, to control the two LED light bars that you specified to require 12 V to 30 V DC at 1730 mA.
It appears from some replies to your original question, that those responses assume you will power the microcontroller from a 22 V to 28 V DC supply, perhaps to be derived from the external equipment the LED lamps will service.
This is almost never a good idea. The real world is hostile to microcontrollers, and hostile to digital logic in general. Microcontrollers and associated logic should be powered separately from the equipment to which it is interfaced, and the interfaces should be
galvanically isolated from the microcontroller and any "
glue logic" you may need. You should choose a microcontroller FIRST, determine what power it requires, and only then finally plan to provide that power independently from whatever microcontroller interfaces are required.
Most microcontrollers will happily operate from a 5 V DC supply, typically obtained from a "wall-wart" fixed-voltage power supply. Almost any "wall-wart" will do. If it provides more than 5 V DC, use a
three-terminal regulator to bring its output down to 5 V or 3.3 V or whatever voltage the microcontroller needs. As suggested in post #3 by
@kellys_eye, you can cascade two of these to drop from a higher voltage down to an intermediate voltage and then finally to the microprocessor operating voltage. You would do this, if necessary, only to remain within the input-to-output voltage limitations of a particular three-terminal regulator. Cascading regulators distributes the power dissipation but does not decrease the power that must be dissipated (thrown away) to bring a too-high supply voltage down to the desired level. I prefer to purchase, or design, a power supply for the microcontroller I will use and set that up first. This allows me to proceed with programming without necessarily having all the peripheral components that will eventually be interfaced to the microcontroller.
You can even use a "wall-wart" that provides only an AC output (usually through a step-down transformer) with only a little more effort: just add a full-wave bridge rectifier and a "smoothing" capacitor to its AC output, ahead of the three-terminal regulator. Whichever method you choose to power the microcontroller, it's power supply remains independent from the equipment interfaced to the microcontroller. There are several very good reasons for doing it this way, the most important being that it helps protect the microcontroller from the real world, which can get really nasty if someone accidentally faults an input signal line to a 220 VAC power distribution line. Stupid happens, but you should try to anticipate it and prevent further damage with conservative design.
All this then leads right into problems (2) and (3), or how to interface the microcontroller to the real world.
Typical microcontroller bit-input ports require binary (on/off) signals that vary between zero volts and perhaps three to five volts maximum, depending on the microcontroller, but as
@kellys_eye noted in post #14, the inputs are relatively high impedance and do not require much current to assert a valid logic-level input. Although a series resistor and a shunt zener diode attached to each input
will work, I think it is
overkill and it does not provide any galvanic isolation of the input to the microcontroller. Unless you require the ability to sense very rapid cycling of the input states, more rapidly than several hundred thousand times per second, it is a good idea to
optically isolate each bit-input with an
optocoupler. These consist of an LED illuminating a photo-transistor, all sealed together in one plastic package, typically a 4-pin or 6-pin DIP. Two external components, a resistor to limit input current to the internal LED and a shunt diode to prevent reverse-biasing of that LED, or to allow operation with AC inputs, are all that is necessary to accommodate any voltage, AC or DC, you care to provide for bit inputs. Sometimes you may need a "pull-up" resistor on the photo-transistor collector to provide a well-defined logic-one level for input to a bit-input port on the microcontroller, although many microcontrollers provide this resistance internally connected to Vcc as a "feature". Check the datasheet of the microcontroller.
Typical microcontroller bit-output ports provide binary (on/off) signals with limited current and voltage capability. These outputs should also be isolated from the real world, but here the choices are many. As you suggested in post #6, a small sensitive electro-mechanical relay will suffice, but this severely limits the rate at which you can cycle the output on and off. It is also prone to "wearing out" since it is a mechanical device. I would suggest using each output bit to drive the optically isolated input of a commercial off-the-shelf (COTS) solid-state switch. You can build-your-own as a DIY project, but this does require more design and construction effort, for which you can find help here if needed. Low voltage microcontrollers may require a "boost" in their output voltage to reliably actuate a COTS solid-state switch. You can easily do this with a small-signal NPN transistor "driver" such as a
2N3904.
The same optoisolators used for galvanic isolation of the input signals can also be used for galvanic isolation of the output signals. For that application, you drive the optoisolator LED with the bit-output of the microcontroller and use the photo-transistor to control a relay, or to drive a power transistor.
Some of your questions indicate a lack of understanding of basic electricity and/or electronics. You can certainly learn a lot of things NOT to do by trial-and-error, but that is a pretty expensive way to learn. A better approach might be to develop some schematics of what you are really trying to DO and post them here for comment and/or advice. Better yet, find a mentor to help you. I have found that a hands-on approach, combined with adequate knowledge of theory, is an excellent way to learn. Your mileage (or kilometers) may differ.