ipcon = IPConnection() # Create IP connection servo = BrickServo(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Configure two servos with voltage 5.5V # Servo 1: Connected to port 0, period of 19.5ms, pulse width of 1 to 2ms # and operating angle -100 to 100° # # Servo 2: Connected to port 5, period of 20ms, pulse width of 0.95 # to 1.95ms and operating angle -90 to 90° servo.set_output_voltage(5500) servo.set_degree(0, -10000, 10000) servo.set_pulse_width(0, 1000, 2000) servo.set_period(0, 19500) servo.set_acceleration(0, 1000) # Slow acceleration servo.set_velocity(0, 65535) # Full speed servo.set_degree(5, -9000, 9000) servo.set_pulse_width(5, 950, 1950) servo.set_period(5, 20000) servo.set_acceleration(5, 65535) # Full acceleration servo.set_velocity(5, 65535) # Full speed servo.set_position(0, 10000) # Set to most right position servo.enable(0) servo.set_position(5, -9000) # Set to most left position servo.enable(5)
y = starty + length * math.sin(radian_angle) return (startx, starty, x, y) if __name__ == "__main__": # Create Brick/Bricklet objects ipcon = IPConnection() oled = BrickletOLED128x64('x5U', ipcon) poti = BrickletRotaryPoti('8Co', ipcon) servo = BrickServo('6e8MF1', ipcon) # Connect to brickd ipcon.connect(HOST, PORT) # Configure Servo so that it rotates 180° servo.set_pulse_width(6, 650, 2350) servo.enable(6) # Clear display oled.clear_display() # Draw text once at beginning, the window in draw_matrix does not overwrite # the last line of the display oled.write_line(7, 5, "tinkerforge.com") # We just use an endless loop here, press ctrl + c to abort the script while True: # With position 110 poti is at 90° angle = poti.get_position() * 90 // 110 if angle > 90: angle = 90
ipcon = IPConnection() # Create IP connection servo = BrickServo(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Configure two servos with voltage 5.5V # Servo 1: Connected to port 0, period of 19.5ms, pulse width of 1 to 2ms # and operating angle -100 to 100° # # Servo 2: Connected to port 5, period of 20ms, pulse width of 0.95 # to 1.95ms and operating angle -90 to 90° servo.set_output_voltage(5500) servo.set_degree(0, -10000, 10000) servo.set_pulse_width(0, 1000, 2000) servo.set_period(0, 19500) servo.set_acceleration(0, 1000) # Slow acceleration servo.set_velocity(0, 65535) # Full speed servo.set_degree(5, -9000, 9000) servo.set_pulse_width(5, 950, 1950) servo.set_period(5, 20000) servo.set_acceleration(5, 65535) # Full acceleration servo.set_velocity(5, 65535) # Full speed servo.set_position(0, 10000) # Set to most right position servo.enable(0) servo.set_position(5, -9000) # Set to most left position servo.enable(5)
x = startx + length * math.cos(radian_angle) y = starty + length * math.sin(radian_angle) return (startx, starty, x, y) if __name__ == "__main__": # Create Brick/Bricklet objects ipcon = IPConnection() oled = BrickletOLED128x64('x5U', ipcon) poti = BrickletRotaryPoti('8Co', ipcon) servo = BrickServo('6e8MF1', ipcon) # Connect to brickd ipcon.connect(HOST, PORT) # Configure Servo so that it rotates 180° servo.set_pulse_width(6, 650, 2350) servo.enable(6) # Clear display oled.clear_display() # Draw text once at beginning, the window in draw_matrix does not overwrite # the last line of the display oled.write_line(7, 5, "tinkerforge.com") # We just use an endless loop here, press ctrl + c to abort the script while True: # With position 110 poti is at 90° angle = poti.get_position()*90//110 if angle > 90: angle = 90