benoit Posted July 9, 2018 at 07:52 PM Share Posted July 9, 2018 at 07:52 PM Hallo zusammen, Ich sehe kein Beispiel für das Digital In Bricklet 2.0. Ich probiere mit Beispiel von 1.0 aber es funktionniert nicht. Ich bräuchte ein callback Beispiel. Kann mich jemand helfen? DANKE Quote Link to comment Share on other sites More sharing options...
borg Posted July 10, 2018 at 09:41 AM Share Posted July 10, 2018 at 09:41 AM Wir hinken leider mit den Beispielen etwas hinterer. Welche Sprache? Quote Link to comment Share on other sites More sharing options...
benoit Posted July 10, 2018 at 11:43 AM Author Share Posted July 10, 2018 at 11:43 AM Danke für die Antwort. Python Quote Link to comment Share on other sites More sharing options...
borg Posted July 10, 2018 at 02:54 PM Share Posted July 10, 2018 at 02:54 PM Beispiel: #!/usr/bin/env python # -*- coding: utf-8 -*- HOST = "localhost" PORT = 4223 UID = "XYZ" # Change XYZ to the UID of your Industrial Digital In 4 Bricklet from tinkerforge.ip_connection import IPConnection from tinkerforge.bricklet_industrial_digital_in_4_v2 import BrickletIndustrialDigitalIn4V2 # Callback function for interrupt callback def cb_all_value(changed, value): print("Changed: " + str(changed)) print("Value: " + str(value)) print("") if __name__ == "__main__": ipcon = IPConnection() # Create IP connection idi4 = BrickletIndustrialDigitalIn4V2(UID, ipcon) # Create device object ipcon.connect(HOST, PORT) # Connect to brickd # Don't use device before ipcon is connected # Callback every 100ms, value does not have to change idi4.set_all_value_callback_configuration(100, False) # Register interrupt callback to function cb_interrupt idi4.register_callback(idi4.CALLBACK_ALL_VALUE, cb_all_value) raw_input("Press key to exit\n") # Use input() in Python 3 ipcon.disconnect() Quote Link to comment Share on other sites More sharing options...
benoit Posted July 11, 2018 at 06:57 PM Author Share Posted July 11, 2018 at 06:57 PM Danke Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.