Hi.
-
You don’t need to use the
$symbol in Python code. That is just there in other parts of psychoPy to indicate that something should be interpreted as Python rather than a literal value. In a code component, everything is code by definition, so $ signs can cause errors. -
Your code above isn’t formatted to show indentations properly, but it should look like this:
if response.corr == 1:
parallel.setData(p_port_1)
else:
parallel.setData(99)
The fact that 99 does appear shows that at least your parallel port is working. So the problem may be that response.corr never evaluates to 1. You’ll need to check that aspect of whether correct responses are detected at all before worrying about the parallel port.
When checking the keyboard, .keys returns a list rather than a single value (notice it’s a plural). So to check it, you have to look for a single entry in the list. Also note that you aren’t surrounding m in quotes, so it is being compared to a variable called m (that probably hasn’t been defined), rather than the literal value 'm'. e.g.
if 'm' in response.keys:
parallel.setData(99)
Lastly, instead of saying "but it didn’t work
", please give us actual error messages or describe exactly what went wrong, so we don’t have to guess.