Simple repeated pin entry task

Hi all,

I am attempting to make a seemingly simple pin entry task, but am running into problems in regards to having the computer check for the correct pin. I can only include 2 media in this post since I am new to psychopy forum and will include a data file and the experiment itself. I will reply to this post with some screenshots of my code as well.

The gist of what I want participants to do is to receive a pin, and then they have to click the pin digits(numbered polygons with a mouse component) in the order they were shown to advance, however I keep getting an incorrect feedback.

So basically what I am doing with code is generating a random number at the start of a loop and calling it Pin. Then I break Pin up into 4 separate str values in the order that it was displayed. The idea is to have a desired_order variable, which is equal to Pin, and is what the computer is checking for in regards to the order of clicked buttons ( numbered polygons with clickable attributes). With my broken up Pin I then assign each str value (1, 2, 3, etc) to the end of polygon. This creates a order that looks something like this: polygon1, polygon2, polygon3 etc. I have my “buttons” named as each respective polygon. However when I run this I always get an incorrect feedback. I do not receive any error messages and when I look at the data, the desired_order variable is equivalent to the order of the buttons that should be pressed. In other words this seems as if it should work, but it is not. I am still fairly new to psychopy and coding so any help would be greatly appreciated! Thank you!

781270_custom_button_order_2024-07-19_11h52.43.759.csv (2.8 KB)

Updated button order.psyexp (91.2 KB)

Hello

try to print mouse_2.clicked_name to the console to check its value.

print(mouse_2.clicked_name)

Tis informs you about the structure of the list provided by the mouse-component.

Best wishes Jens

1 Like

Hi Jens,

Thank you for the tip. After realizing that the order variable was not equaling to the clicked values, I was able to get it too work. I simply changed the order variable to be equal to what I had the P1- P4 values equal too. However, now that the computer is checking correctly, the routine is not repeating as I hoped it would. I am trying to have the loop repeat once the correct answer is given. Do you have any tips on making this work, I would appreciate it very much.

Thank you,

Will


Hello Will

Do you mind to show how you repeat your loop?

BTW

continueRoutine = True

is the default. So, it is not needed.

Best wishes Jens

Hey Jens,

So basically what is happening is whether the answer is correct or incorrect, I seem to be stuck in the trials_2 loop. In reality once the answer is correct I should break out of trials_2 loop and go back to trials_3 loop. In this loop a new number is given as a pin (in the “next” routine) and the task is repeated.

Also thank you for the tip on the continueRoutine, I had a suspicion about it not being needed but wasn’t sure.

Thank you,

Will

Hello

This might do the trick

Best wishes Jens