python - Raspberry PI - Error accessing 0x40: Check your I2C address -
i seek run python servo script on raspberry pi. got code here
https://github.com/adafruit/adafruit-raspberry-pi-python-code/blob/master/adafruit_pwm_servo_driver/servo_example.py
python servo script
#!/usr/bin/python adafruit_pwm_servo_driver import pwm import time # =========================================================================== # illustration code # =========================================================================== # initialise pwm device using default address # bmp = pwm(0x40, debug=true) pwm = pwm(0x40, debug=true) servomin = 150 # min pulse length out of 4096 servomax = 600 # max pulse length out of 4096 def setservopulse(channel, pulse): pulselength = 1000000 # 1,000,000 per sec pulselength /= 60 # 60 hz print "%d per period" % pulselength pulselength /= 4096 # 12 bits of resolution print "%d per bit" % pulselength pulse *= 1000 pulse /= pulselength pwm.setpwm(channel, 0, pulse) pwm.setpwmfreq(60) # set frequency 60 hz while (true): # alter speed of continuous servo on channel o pwm.setpwm(0, 0, servomin) time.sleep(1) pwm.setpwm(0, 0, servomax) time.sleep(1) i seek solution not helping.
https://learn.adafruit.com/downloads/pdf/adafruit-16-channel-servo-driver-with-raspberry-pi.pdf
please advice.
first of all, don't want logged root everytime: set sudo when need , type password.
second: i2c bus not configured or wiring wrong. the command i2cdetect doesn't see attached. have installed smbus , i2ctools, have removed i2c-bcm2708 blacklist? need type:
sudo nano /etc/modprobe.d/raspi-blacklist.conf and add together # line i2c-dev , i2c-bcm2708.
from:
blacklist i2c-dev blacklist i2c-bcm2708 to:
#blacklist i2c-dev #blacklist i2c-bcm2708 than need add together modules i2c @ startup
sudo nano /etc/modules and add together these 2 lines end of file:
i2c-bcm2708 i2c-dev now can manually load these modules commands
sudo modprobe i2c-bcm2708 sudo modprobe i2c-dev now type 1 time again :
sudo i2cdetect -y 0 #if have rev1 board sudo i2cdetect -y 1 #if have rev2 board now, if see dots in chart (like before), check wiring. if see something, that's address of servo driver.
python linux raspberry-pi
No comments:
Post a Comment