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,

 

ich habe mal eine Frage zu dem IO-Bricklet.

Da gibt es das io.set_Value(...).

So wie ich es lese kann man z.B. mit dem Befehl in einem Rutsch alle Ausgänge auf 0 (False) setzen. Oder Ausgang 0 auf False, Ausgang 1 auf True...

Das dann mit den Befehlen:

io.set_value(False, False, False, False)      alle Ausgänge auf 0 gesetzt

io.set_value(False, True, True, True)            Ausgang 0 auf False, Ausgang 1 auf True...

Aber das funktioniert so leider nicht.

Ich habe das Beispielprogramm genommen und nur minimal geändert, aber es funktioniert nicht.

Hier das Programm:

 

HOST = "localhost"
PORT = 4223
UID = "G6j" # Change XYZ to the UID of your IO-4 Bricklet 2.0

import time

from tinkerforge.ip_connection import IPConnection
from tinkerforge.bricklet_io4_v2 import BrickletIO4V2


ipcon = IPConnection() # Create IP connection
io = BrickletIO4V2(UID, ipcon) # Create device object

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

# Configure channel 3 as output low
io.set_configuration(0, "o", False)
io.set_configuration(1, "o", False)
io.set_configuration(2, "o", False)
io.set_configuration(3, "o", False)

io.set_value(False, False, True, True)


input("Press key to exit\n") # Use raw_input() in Python 2
ipcon.disconnect()

 

Als Fehlermeldung kommt:

Traceback (most recent call last):
  File "D:/Daten/Python_eigenePrg/Tinkerforgeprg/Test.py", line 23, in <module>
    io.set_value(False, False, True, True)
TypeError: set_value() takes 2 positional arguments but 5 were given

Wieso 2 erwartet und 5 bekommen??

Kann mir das einer erklären?

 

Danke im Voraus.

 

 

 

Geschrieben

Moin,

Die Doku sagt, dass du set_value ein value vom Typ [bool, ...] der Länge: 4 mitgeben musst. Das heißt, dass value eine Liste ist. So sollte es funktionieren:

io.set_value([False, False, True, True])

 

Geschrieben
  • Autor

Hallo rtrbt,

vielen vielen Dank.

Ich bin noch neu in Python und habe die Klammerinhalte einfach aus der Doku übernommen.

Wieder etwas gelernt. 

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.