I am looking to use UNO R3, L298N Motor Driver and KY-040. I was wondering what pin selection would work best.
Would the same pin selection work on a Nano as well.
I would only be using one motor driver 'A' and one rotary encoder,
Thanks in advance.
My apology - I see that I have asked this previously.
What motor do You intend to use? L298N is a really old, stone age, driver that waists voltage and power. MOSFET drivers are better. In case of one way rotation a logic level N channel MOSFET is a better alternative.
To start make a sketch that runs the decoder.
Then make a sketch for the motor control, what ever it will be. Finally merge the experiences.
I have a number of L298N Motor Driver's so I have to use them.
My project is done - but looking at it I wonder if I could better it by using different pins on the UNO R3.
Those pins looks not good to me. D0 and D1 are used for both downloading code as well as the USB serial communication with the Pc, valuable in debugging.
Use D2 and/or D3for the encoder. Some decoders run on one interrupt capable pin, some might need 2 pins like that. When that works, almost all other pins are good for the motor control. Note which pins handle PWM if You want speed control.
Look for logic level N channel MOSFET. The gate source voltage for fully turned on is the key parameter. Switching the low side of loads using a serial gate resistor of some 180 Ohm and a gate to source resistor of some 10k they are both voltage and energy effective.