Guide by Brenton; Makerverse Motor Driver, 2 Channel - Application Guide

Hi John,

Perhaps it is best to start from scratch here so we can eliminate any possible errors. Let’s test only the motor driver code by itself to start. It could be that there are some conflicts with the ESP32.

Download the module again and see if you can follow the first example here.

from Makerverse_Motor_2ch import motor

m1 = motor(pwmPin = 0, dirPin = 1)
m1.go()

No problem with this code.

What else did you have connected to your ESP when you experienced the error?

Could you also try this at a lower frequency?

Very strange behaviour! Using Thonny whichever of programs I import first (your test code or my original code). I get the error. If I import the alternative code after it will run.
It appears that
m1 = motor(pwmPin = 0, dirPin = 1)

throws the error until it is run again in the new code.

Added

try:
m1 = motor(pwmPin = 0, dirPin = 1)
except:
m1 = motor(pwmPin = 0, dirPin = 1)
and it now works !

Thanks Jack. Nothing else connected and I did not set any frequency. See. posts below how I have resolved it. It would be better if this was not necessary.
Chhers

2 Likes

Hi @John122579,

Glad to hear you got it working.

Very weird bug indeed.

Hi Guys
When I try and run this from the guide it says it cant import the name motor

from Makerverse_Motor_2ch import motor
import time

m1 = motor()

for speed in range(-100,100,5):
    print(speed)
    m1.speed(speed)
    time.sleep_ms(300)

error

Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: can't import name motor

cheers
Nick

Hey @Nicholas193967 ,

I ran through this guide quickly with a Pico and was able to import motor from Makerverse_Motor_2ch without an issue. Is it possible that Makerverse_Motor_2ch.py is not uploaded to your Pico or is in a directory where your code cannot see it?

If you are using Thonny, the file structure of your Pico should look something like this, with the Makerverse_Motor_2ch.py code sitting next to your main code or whichever file contains the code you sent above.

Hope this helps!

1 Like

Hi Samuel
Thanks for your reply . I have the Makerverse _Motor_2ch.py in the format as you do but it still did not work at the time , but I have not managed to get it running .
Not sure what I did but it is going
cheers
Nick

1 Like

Glad to hear that you got it running, @Nicholas193967, even if you don’t have a definite answer for what changed.