from Adafruit_PWM_Servo_Driver import PWM import time
# Initialise the PWM device using the default address pwm = PWM(0x40) # Note if you'd like more debug output you can instead run: #pwm = PWM(0x40, debug=True)
servoMin = 150 # Min pulse length out of 4096 servoMax = 600 # Max pulse length out of 4096 servoMid = 375 # Mid pulse length out of 4096
def setServoPulse(channel, pulse): pulseLength = 1000000 # 1,000,000 us per second pulseLength /= 60 # 60 Hz print "%d us per period" % pulseLength pulseLength /= 4096 # 12 bits of resolution print "%d us per bit" % pulseLength pulse *= 1000 pulse /= pulseLength pwm.setPWM(channel, 0, pulse)
pwm.setPWMFreq(60) # Set frequency to 60 Hz # Change speed of continuous servo on channel O # Forward #Motion 1 for i in range(0,3): pwm.setPWM(0, 0, 300) # Right front root pwm.setPWM(1, 0, 450) # Right front leg
pwm.setPWM(2, 0, 375) # Left front leg pwm.setPWM(3, 0, 375) # Left front root
pwm.setPWM(4, 0, 375) # Right rear leg pwm.setPWM(5, 0, 375) # Right rear root
from Adafruit_PWM_Servo_Driver import PWM import time
# Initialise the PWM device using the default address pwm = PWM(0x40) # Note if you'd like more debug output you can instead run: #pwm = PWM(0x40, debug=True)
servoMin = 150 # Min pulse length out of 4096 servoMax = 600 # Max pulse length out of 4096 servoMid = 375 # Mid pulse length out of 4096
def setServoPulse(channel, pulse): pulseLength = 1000000 # 1,000,000 us per second pulseLength /= 60 # 60 Hz print "%d us per period" % pulseLength pulseLength /= 4096 # 12 bits of resolution print "%d us per bit" % pulseLength pulse *= 1000 pulse /= pulseLength pwm.setPWM(channel, 0, pulse)
pwm.setPWMFreq(60) # Set frequency to 60 Hz # Change speed of continuous servo on channel O # Right turn #Motion 1 for i in range(0,8) pwm.setPWM(0, 0, 375) # Right front root pwm.setPWM(1, 0, 375) # Right front leg
pwm.setPWM(2, 0, 300) # Left front leg pwm.setPWM(3, 0, 450) # Left front root
pwm.setPWM(4, 0, 375) # Right rear leg pwm.setPWM(5, 0, 375) # Right rear root
from Adafruit_PWM_Servo_Driver import PWM import time
# Initialise the PWM device using the default address pwm = PWM(0x40) # Note if you'd like more debug output you can instead run: #pwm = PWM(0x40, debug=True)
servoMin = 150 # Min pulse length out of 4096 servoMax = 600 # Max pulse length out of 4096 servoMid = 375 # Mid pulse length out of 4096
def setServoPulse(channel, pulse): pulseLength = 1000000 # 1,000,000 us per second pulseLength /= 60 # 60 Hz print "%d us per period" % pulseLength pulseLength /= 4096 # 12 bits of resolution print "%d us per bit" % pulseLength pulse *= 1000 pulse /= pulseLength pwm.setPWM(channel, 0, pulse)
pwm.setPWMFreq(60) # Set frequency to 60 Hz # Change speed of continuous servo on channel O # Left turn #Motion 1 for i in range(0,8): pwm.setPWM(0, 0, 300) # Right front root pwm.setPWM(1, 0, 450) # Right front leg
pwm.setPWM(2, 0, 375) # Left front leg pwm.setPWM(3, 0, 375) # Left front root
pwm.setPWM(4, 0, 375) # Right rear leg pwm.setPWM(5, 0, 375) # Right rear root
from Adafruit_PWM_Servo_Driver import PWM import time
# Initialise the PWM device using the default address pwm = PWM(0x40) # Note if you'd like more debug output you can instead run: #pwm = PWM(0x40, debug=True)
servoMin = 150 # Min pulse length out of 4096 servoMax = 600 # Max pulse length out of 4096 servoMid = 375 # Mid pulse length out of 4096
def setServoPulse(channel, pulse): pulseLength = 1000000 # 1,000,000 us per second pulseLength /= 60 # 60 Hz print "%d us per period" % pulseLength pulseLength /= 4096 # 12 bits of resolution print "%d us per bit" % pulseLength pulse *= 1000 pulse /= pulseLength pwm.setPWM(channel, 0, pulse)
pwm.setPWMFreq(60) # Set frequency to 60 Hz # Change speed of continuous servo on channel O # Backward #Motion 1 for i in range(0,3): pwm.setPWM(0, 0, 300) # Right front root pwm.setPWM(1, 0, 300) # Right front leg
pwm.setPWM(2, 0, 375) # Left front leg pwm.setPWM(3, 0, 375) # Left front root
pwm.setPWM(4, 0, 375) # Right rear leg pwm.setPWM(5, 0, 375) # Right rear root
#include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup() { Serial.begin(9600) ; lcd.init(); lcd.backlight(); } void loop() { int ans ; float volt ; float distance ;
ans = analogRead(0) ; volt = ans * 5.0 / 1023 ; distance = ( 18.679 / volt ) -4.774 ; //Serial.println(ans) ; lcd.print(distance); delay(300) ; lcd.clear(); }
#include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display void setup() { Serial.begin(9600) ; lcd.init(); lcd.backlight(); } void loop() { int ans ; float volt ; float distance ;
ans = analogRead(0) ; volt = ans * 5.0 / 1023 ; distance = ( 9.5974 / volt ) -3.0086 ; Serial.println(ans) ; lcd.print(distance); lcd.print("m"); delay(300) ; lcd.clear(); }
最近のコメント