stepper.stop() elif distance <= 130: print("Stepper -> Zurück") stepper.drive_backward() else: print("Puffer erreicht") stepper.stop() if __name__ == "__main__": ipcon = IPConnection() dcb = BrickDC(UIDdcb, ipcon) oled = BrickletOLED128x64(UIDoled, ipcon) poti = BrickletLinearPoti(UIDpoti, ipcon) ropoti = BrickletRotaryPoti(UIDropoti, ipcon) stepper = BrickStepper(UIDstepper, ipcon) joystick = BrickletJoystick(UIDjoystick, ipcon) irsensor = BrickletDistanceIR(UIDirsensor, ipcon) ipcon.connect(HOST, PORT) print("Verbindung unter folgenden Daten: \nIP: " + HOST + "\nPort: " + PORT) o_clear() print("Einstellungen werden gesetzt") o_write(1, 5, "Einstellungen") o_write(1, 5, "werden gesetzt") ctrl_hz_fan = 5000 dcb.set_pwm_frequency(5000)
#!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "XYZ" # Change XYZ to the UID of your Rotary Poti Bricklet from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_rotary_poti import BrickletRotaryPoti if __name__ == "__main__": ipcon = IPConnection() # Create IP connection rp = BrickletRotaryPoti(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Get current position position = rp.get_position() print("Position: " + str(position)) # Range: -150 to 150 raw_input("Press key to exit\n") # Use input() in Python 3 ipcon.disconnect()
# -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "XYZ" # Change XYZ to the UID of your Rotary Poti Bricklet from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_rotary_poti import BrickletRotaryPoti # Callback function for position callback (parameter has range -150 to 150) def cb_position(position): print("Position: " + str(position)) if __name__ == "__main__": ipcon = IPConnection() # Create IP connection rp = BrickletRotaryPoti(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Register position callback to function cb_position rp.register_callback(rp.CALLBACK_POSITION, cb_position) # Set period for position callback to 0.05s (50ms) # Note: The position callback is only called every 0.05 seconds # if the position has changed since the last call! rp.set_position_callback_period(50) raw_input("Press key to exit\n") # Use input() in Python 3 ipcon.disconnect()
#!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "XYZ" # Change XYZ to the UID of your Rotary Poti Bricklet from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_rotary_poti import BrickletRotaryPoti if __name__ == "__main__": ipcon = IPConnection() # Create IP connection rp = BrickletRotaryPoti(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Get current position (range is -150 to 150) position = rp.get_position() print("Position: " + str(position)) raw_input("Press key to exit\n") # Use input() in Python 3 ipcon.disconnect()
for i in range(len(column)): oled.write(column[i]) def line_at_angle(startx, starty, angle, length): radian_angle = math.pi * angle / 180.0 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")
oled.new_window(0, SCREEN_WIDTH-1, 0, 6) for i in range(len(column)): oled.write(column[i]) def line_at_angle(startx, starty, angle, length): radian_angle = math.pi * angle / 180.0 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")
def create_instance(self, uid, ipcon): return BrickletRotaryPoti(uid, ipcon)