This circuit is espacially interesting if you have to drive bigger loads with variable input current, e.g. motors etc.

This circuit will ensure that the current will max out at a preset value and cannot go any higher. Assuming you are using a microcontroller for logic levels, the circuit may look like this:

Credit: Chris Gammel

The interesting thing: if Q7 is turned on, current will flow through R21. If this current reaches 7A, the voltage drop over R21 becomes 0.7V which is the voltage needed to drive Q8. Q8 then slowly turns down Q7 in order to maintain 7A through J4.

This circuit shows how a constant current source is built. In case the current tries to exceed 7A, it just regulates Q7 and maintains 7A protecting the device at J4 this way. But be aware of the power dissipation! R21 will dissipate up to 4.9W ad Q7 even more, depending on your voltage! Better use a heatsink for Q7.