我正在尝试使用 python 代码控制步进电机。我知道这可能不是最好的方法,但请帮助我并忍受我。不久前我得到了这个工作,我很确定,我不知道为什么这不起作用。请帮助这是我下面的代码
def motor_run_till_press(btnPin, clockwise):
import gpiozero
button = gpiozero.Button(btnPin) #declares the limir switch
def motor_on(clockwise):
import os
os.system("cd /home/pi/printer/A4988CustomFeatures && python3 motor_file_for_kill.py")
from threading import Thread
motor_thread = Thread(target=motor_on, args=[clockwise])
motor_thread.start()
pressed = button.is_pressed()
while True:
if pressed:
import sys
sys.path.append('/home/pi/printer/A4988CustomFeatures')
import kill_motor as killMotor
try:
motor_thread.join()
finally:
return(True)
else:
pass
```
This is the error i get
Traceback (most recent call last):
File "/home/pi/printer/Debug/main.py", line 14, in <module>
motor.motor_run_till_press(17, True)
File "/home/pi/printer/A4988CustomFeatures/BTN_control.py", line 15, in motor_run_till_press
pressed = button.is_pressed()
TypeError: 'bool' object is not callable