# -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "XYZ" # Change XYZ to the UID of your Linear Poti Bricklet from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_linear_poti import BrickletLinearPoti # Callback function for position callback (parameter has range 0 to 100) def cb_position(position): print("Position: " + str(position)) if __name__ == "__main__": ipcon = IPConnection() # Create IP connection lp = BrickletLinearPoti(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 lp.register_callback(lp.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! lp.set_position_callback_period(50) raw_input("Press key to exit\n") # Use input() in Python 3 ipcon.disconnect()
HOST = "localhost" PORT = 4223 UID = "XYZ" # Change XYZ to the UID of your Linear Poti Bricklet from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_linear_poti import BrickletLinearPoti # Callback function for position callback (parameter has range 0 to 100) def cb_position(position): print("Position: " + str(position)) if __name__ == "__main__": ipcon = IPConnection() # Create IP connection lp = BrickletLinearPoti(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 lp.register_callback(lp.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! lp.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 Linear Poti Bricklet from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_linear_poti import BrickletLinearPoti if __name__ == "__main__": ipcon = IPConnection() # Create IP connection lp = BrickletLinearPoti(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Get current position position = lp.get_position() print("Position: " + str(position)) # Range: 0 to 100 raw_input("Press key to exit\n") # Use input() in Python 3 ipcon.disconnect()
print("Stepper -> Stop") 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
#!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "XYZ" # Change XYZ to the UID of your Linear Poti Bricklet from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_linear_poti import BrickletLinearPoti if __name__ == "__main__": ipcon = IPConnection() # Create IP connection lp = BrickletLinearPoti(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 0 to 100) position = lp.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 BrickletLinearPoti(uid, ipcon)