###前提・実現したいこと
PCA9685でサーボモータを回したいのですがうまくいきません。
Raspberrypi3modelBを使っています。
sshでmacと繋いで実行しています。
PCA9685とRaspberrypiは繋いでいます。
また、i2cはON、
sudo apt-get install python-smbus
も試しましたがダメでした。
https://github.com/adafruit/Adafruit_Python_PureIO.git
https://github.com/adafruit/Adafruit_Python_GPIO.git
も入れてあります。
よろしくお願いします。
###発生している問題・エラーメッセージ
pi@raspberrypi:~/Adafruit_Python_PCA9685/examples $ python simpletest.py Traceback (most recent call last): File "simpletest.py", line 17, in <module> pwm = Adafruit_PCA9685.PCA9685() File "build/bdist.linux-armv7l/egg/Adafruit_PCA9685/PCA9685.py", line 75, in __init__ File "build/bdist.linux-armv7l/egg/Adafruit_PCA9685/PCA9685.py", line 111, in set_all_pwm File "build/bdist.linux-armv7l/egg/Adafruit_GPIO/I2C.py", line 115, in write8 File "build/bdist.linux-armv7l/egg/Adafruit_PureIO/smbus.py", line 236, in write_byte_data IOError: [Errno 121] Remote I/O error
###該当のソースコード
https://github.com/adafruit/Adafruit_Python_PCA9685
のサンプルコードを使っています。
python
1# Simple demo of of the PCA9685 PWM servo/LED controller library. 2# This will move channel 0 from min to max position repeatedly. 3# Author: Tony DiCola 4# License: Public Domain 5from __future__ import division 6import time 7 8# Import the PCA9685 module. 9import Adafruit_PCA9685 10 11 12# Uncomment to enable debug output. 13#import logging 14#logging.basicConfig(level=logging.DEBUG) 15 16# Initialise the PCA9685 using the default address (0x40). 17pwm = Adafruit_PCA9685.PCA9685() 18 19# Alternatively specify a different address and/or bus: 20#pwm = Adafruit_PCA9685.PCA9685(address=0x41, busnum=2) 21 22# Configure min and max servo pulse lengths 23servo_min = 150 # Min pulse length out of 4096 24servo_max = 600 # Max pulse length out of 4096 25 26# Helper function to make setting a servo pulse width simpler. 27def set_servo_pulse(channel, pulse): 28 pulse_length = 1000000 # 1,000,000 us per second 29 pulse_length //= 60 # 60 Hz 30 print('{0}us per period'.format(pulse_length)) 31 pulse_length //= 4096 # 12 bits of resolution 32 print('{0}us per bit'.format(pulse_length)) 33 pulse *= 1000 34 pulse //= pulse_length 35 pwm.set_pwm(channel, 0, pulse) 36 37# Set frequency to 60hz, good for servos. 38pwm.set_pwm_freq(60) 39 40print('Moving servo on channel 0, press Ctrl-C to quit...') 41while True: 42 # Move servo on channel O between extremes. 43 pwm.set_pwm(0, 0, servo_min) 44 time.sleep(1) 45 pwm.set_pwm(0, 0, servo_max) 46 time.sleep(1)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。