Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5190

MicroPython • L298N Motor Driver (MicroPython) motor only works in one direction?

$
0
0
Good Day PI'ers

I have a pico running MicroPython v1.23 with L298N and 2 motors https://www.amazon.com/gp/product/B0CG1C7T8J

One of the motor controllers works great (forward and backward).

The other works (but it moves the wheel backward and backward) :D

I am not even trying PWM yet. Just testing forward and back.

Code:

### Observed Truth Table########## Right ##########                     <==WORKS GREAT!MC2_A1A = Pin(0, Pin.OUT)MC2_A1B = Pin(1, Pin.OUT)#ForwardMC2_A1A.value(1) ; MC2_A1B.value(0)time.sleep(sleep)#StopMC2_A1A.value(1) ; MC2_A1B.value(1)time.sleep(sleep)#BackwardMC2_A1A.value(0) ; MC2_A1B.value(1)time.sleep(sleep)#StopMC2_A1A.value(0) ; MC2_A1B.value(0)time.sleep(sleep)########## Left ##########MC1_A1A = Pin(2, Pin.OUT)MC1_A1B = Pin(3, Pin.OUT)#Backward                                                          <====== Both spin the wheel backward!MC1_A1A.value(1) ; MC1_A1B.value(1)time.sleep(sleep)#StopMC1_A1A.value(0) ; MC1_A1B.value(0)time.sleep(sleep)#Backward                                                         <====== Both spin the wheel backward!MC1_A1A.value(1) ; MC1_A1B.value(0)time.sleep(sleep)#StopMC1_A1A.value(0) ; MC1_A1B.value(1)time.sleep(sleep)"""
I am powering the pico with a 5V USB cable.

I am externally powering the L298N with a separate 5V USB cable (and using the 12 V terminal and not the 5V terminal - I believe I need to do that to power both chip and motors). (per https://randomnerdtutorials.com/raspber ... cropython/)

I have left both enable jumpers on.

Some pics I hope help:

Anything obvious here? Shall I post more information?
qq (1).png

PXL_20241001_024519039 (1).jpg

PXL_20241001_024732527 (1).jpg

Statistics: Posted by raspmod — Tue Oct 01, 2024 3:12 am



Viewing all articles
Browse latest Browse all 5190

Trending Articles