Pwm dc motor not stopping although motor1.throttle = 0

I use
import RPi.gpio as gpio
gpiosetmode(board)
p.pwm(33, 100) etc
but these code got error when using pca9685 servokit together
which is “different mode has already set”
so I find something different code that adafruit_pca 9685, adafruit_motor
I think it works good, because there is no crash and controling dc motor speed is work
but my code motor1.throttle =0 is not working
motor1.throttle=0 is dc motor stop code
L dc motor not stopping but working with low speed

I don’t know why these error is work :( could you help me?

my full code is

from board import SCL, SDA
from adafruit_pca9685 import PCA9685
from adafruit_motor import motor

i2c = busio,I2 (SCL, SDA)

pca = PCA9685(i2c, address=0x40)
pca.frequnecy =100
pca.channels[8].duty_cycle = 0xFFFF

motor1 = motor.DCMotor(pca.channels[9], pca.channels[10])

motor1.throttle = 0.5
time.sleep(3)

motor1.throttle = 1
time,sleep(3)

motor1.throttle = 0
tiem,sleep(3)

pca,deinit()

hello hwooin99,

you should look into the sources, there should be settings assigned. please revise the code to adapt with your use-case,
besides, please refer to Topic 178959 as see-also for using Nano’s PWM.
thanks

thanks for answering

I found why ValueError : a differnet mode has alreday been set

it’s because of import cv2
in Jetson/GPIO/gpio,py line 317 there is four mode : board, bcm, cvm ,tegra_soc
I think there is two mode in jetson, but three is four mode so when i change my code GPIO.setmode(GPIO.BOARD) to GPIO.setmode(GPIO.BCM) there is value error because my mode is cvm I guess.
I find RPI.GPIO and cv2 can’t use together. I think I have to use RPI.ZERO

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.