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)
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")
#!/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()
def create_instance(self, uid, ipcon): return BrickletRotaryPoti(uid, ipcon)