Jump to content
View in the app

A better way to browse. Learn more.

Tinkerunity

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Geschrieben

Hallo zusammen,

ich habe folgendes Problem:

Ich habe einen DualButton und möchte Testweise die linke LED mit Python einschalten.

Ich habe das Beispielprogramm genommen und erweitert, aber es will nicht so wie ich will.

 

HOST = "localhost"
PORT = 4223
UID_dualButton = "MeA"                                                           # Change XYZ to the UID of your Dual Button Bricklet 2.0

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_dual_button_v2 import BrickletDualButtonV2

def cb_state_changed(dualbutton_l, dualbutton_r, led_l, led_r):              # Callback function for state changed callback
    if dualbutton_l == BrickletDualButtonV2.BUTTON_STATE_PRESSED:
        print("Linker Button: gedrückt")
    elif dualbutton_l == BrickletDualButtonV2.BUTTON_STATE_RELEASED:
        print("Linker Button: nicht gedrückt")

    if dualbutton_r == BrickletDualButtonV2.BUTTON_STATE_PRESSED:
        print("Rechter Button: gedrückt")
    elif dualbutton_r == BrickletDualButtonV2.BUTTON_STATE_RELEASED:
        print("Rechter Button: nicht gedrückt")
    print("")

if __name__ == "__main__":
    ipcon = IPConnection()                                                          # Create IP connection
    db = BrickletDualButtonV2(UID_dualButton, ipcon)                        # Create device object

    ipcon.connect(HOST, PORT)                                                   # Connect to brickd
    # Don't use device before ipcon is connected

 

#------------------------------

 Dies sind meine Versuche
    #db.setLEDState(BrickletDualButton.LED_STATE_ON, BrickletDualButton.LED_STATE_OFF)
    # db.set_selected_led_state(BrickletDualButtonV2.LED_STATE_OFF, BrickletDualButtonV2.LED_STATE_ON)
    #db.BrickletDualButtonV2.set_selected_led_state(0, 2)
    #print(BrickletDualButtonV2.get_led_state())
    # BrickletDualButtonV2.set_selected_led_state(0, 2)
    # BrickletDualButtonV2.set_led_state(2, 2)

#-----------------------------

 

    # Register state changed callback to function cb_state_changed
    db.register_callback(db.CALLBACK_STATE_CHANGED, cb_state_changed)
    db.set_state_changed_callback_configuration(True)                       # Enable state changed callback

    input("Press key to exit\n")
    ipcon.disconnect()
 

Wo ist da der Fehler?

 

Vielen Dank im Voraus.

 

 

Geschrieben

Moin,

Versuche mal set_led_state, wie hier beschrieben:

db.set_led_state(BrickletDualButtonV2.LED_STATE_OFF, BrickletDualButtonV2.LED_STATE_ON)

Bei den Konstantennamen musst du darauf achten, die vom BrickletDualButtonV2 zu benutzen, nicht die vom BrickletDualButton.

Geschrieben
  • Autor

Hallo rtrbt,

 

vielen Dank für den Tipp.

Habe das V2 nicht gesehen. Werde ab jetzt genau drauf achten.

 

Läuft jetzt super.

Vielen Dank.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.