LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

somebody help me creating program

Solved!
Go to solution

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

0 Kudos
Message 1 of 6
(2,063 Views)
Solution
Accepted by topic author ddfrds21

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:

  • Initialize all the values (-> Sequence Structure)
  • Continuously (-> While Loop) watch for User Input (->Event Structure)

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

0 Kudos
Message 2 of 6
(2,034 Views)

lab.png

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 ~~

0 Kudos
Message 3 of 6
(2,025 Views)
Solution
Accepted by topic author ddfrds21

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

  • Read the current state of the button
  • If the button is pressed, read the user's guess and increase the number of guesses
  • If the guess is correct: Display the number of guesses, Switch the LED and exit the program
  • If the guess is not correct: Return to the top
0 Kudos
Message 4 of 6
(2,013 Views)

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

aa.png

 

0 Kudos
Message 5 of 6
(1,987 Views)

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!

0 Kudos
Message 6 of 6
(1,918 Views)