04-25-2020 03:26 AM
Create a start button on the front panel to start the game.
Two integers are randomly generated and displayed on the front panel.
The user calculates the sum of the two integers and inputs the calculated value into the font panel.. Press the OK button to make sure that it is the correct answer.
If the entered value is correct, the green light comes on, and if it is wrong, the red light comes on.
The calculated value must be entered again until the correct value is entered.
The number of attempts to enter the calculated value until the correct answer is entered is displayed on the front panel, and the program ends.
help me
Solved! Go to Solution.
04-25-2020 04:42 AM
What part of the problem do you need help with?
This sounds like a study exercise - if this is correct, can You show us the course materials?
For the program itself, the description is very good and lays out what the program needs to do:
When creating a new VI, there is a template you can use for that (see under Templates/Framework). If You have trouble using the basic tools, I recommend taking a look at the CORE training courses here, since they are freely avaiable for the next few days: https://learn.ni.com/training/resources
04-25-2020 05:00 AM - edited 04-25-2020 05:01 AM
i made it up to here
but the count isn't increase and when i apply the wrong answer, the boolean is always green light( i set the boolean on: green off: red)
i can't use the OK button, it isn't work
help me ~~
04-25-2020 05:21 AM
You are trying to repeatedly poll the OK button, but the value never changes. The State of the OK button is only tested at the start of the program. Every time the while loop runs, it will see the same state of the button. You have to move it inside the while loop.
The For loop is not suitable for your problem, because there is no limit on how many times the button can be pressed.
You will want to repeatedly
04-25-2020 08:01 AM - edited 04-25-2020 08:34 AM
as you say, i use the event structure. so now i can repeat the progress.
really thank you!!!
but there are still not correct.
when i write the correct answer, the program is not stop immediately.
i have to push the button twice
and tell me how can i set the boolean reset when i start the program
04-26-2020 12:40 AM
I can't read your text to know exactly what each control is.
But I am pretty sure your numeric control that would be the guess belongs in the event case. Because right now it is read early in the iteration of the loop, then execution pauses at the event structure. If the user changes the value, it won't be read until the next iteration after the user hits the boolean button. Then the new value gets read, a true is sent to the stop terminal, and it waits at the event structure again waiting for button press.
Turn on highlight execution and watch the data flow so you'll understand!