Jump to content

Recommended Posts

Posted

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.

 

 

 

Posted

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])

 

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...