May I use two Raspberry Pi's 5V output to power in both 12V and 5V of the L298N?
No. There is no reasonable way to use the 5V of the Pi to get to 12V. There is also no such thing as "two" 5V outputs of the Pi. It is one and the same voltage level on all 5V pins. (But I might have gotten your question wrong here.)
Maybe yes. The input voltage of the L298N module is to be selected according to the motors you want to drive. The respective power supply needs to provide this voltage and the current required. If your motors happen to run at 5V it is theoretically possible to run from the same supply as the Pi - if said power supply can provide enough current for both the Pi and the motors. With all the troubles that might arise from driving an inductive load - decoupling of both circuits is advised (I'd suggest to look into LC circuits, e.g. here: https://electronics.stackexchange.com/).
On a sidenote: mind the TTL compatible logic inputs of the L298N and the 3V3 logic level of the Pi's GPIO pins.
Lets check the datasheet:
- Supply voltage V_S = (V_IH + 2.5V) to 45V (ok with 5V, see below note on V_IH)
- Logic level voltage V_SS = 4.5V to 7V (ok with 5V)
- Logic low V_IL < 1.5V (nothing that concerns us right now)
- Logic high V_IH = 2.3V to V_SS (ok, as the Pi's GPIO output high should be anywhere between 2.4V and 3.3V, see here)
- Logic input current: < 100 µA (nothing to worry about)
So, yes, theoretically it is possible to drive the board from the Pi's 5V supply, given a high enough current rating of the power supply, decoupling, and motors that run well with significantly less than 5V (due to the voltage drop of the switching transistors in the L298N (refer to saturation voltage in the datasheet)).
The motor's MDN4RB3SXA spec says:
- Operating voltage: 1V to 6V (ratings at 3V)
- No load current: 12mA
- Rated current: 32mA
So it would seem that the voltage drop across the L298N is not an issue either. Given all this it would seem that this could in fact work.