LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I generate a single random number on button press for use elsewhere in a VI?

Solved!
Go to solution

I'm creating a new VI and need a new random number each time I hit a button... this will eventually be replaced with en externally triggered boolean, but for now, I'd like to just hit a button, get a new number, use that number, hit the button, get a new number (erase previous), etc etc.

 

Thanks, 

-Steve

0 Kudos
Message 1 of 7
(5,939 Views)

OK. What have you tried? There's a random number function in the Numerics tab. All you need is a front panel with 2 buttons (Generate and Stop) and an indicator. In the code all you need is a while loop with an event structure. I'd give you the code, but then you should really try this yourself.

 

Have you taken any of the LabVIEW tutorials? To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

0 Kudos
Message 2 of 7
(5,928 Views)

Hi Steve...

as  told, You have to got through the basic training material....

But any way for your referance... Try this...

Rand.jpg

 

<<Kudos are welcome>>

Message 3 of 7
(5,904 Views)

Why the case statement? You can eliminate that.

0 Kudos
Message 4 of 7
(5,900 Views)

Hi Dennis...

You are right.. By mistake, in the flow. I just put it....

Sorry for the inconvenience...

 

<<Kudos are welcome>>

0 Kudos
Message 5 of 7
(5,894 Views)
Solution
Accepted by topic author jamison.39

Just to add up what SAM has posted you can generate in a different ranges without limiting it.. Its just a very simple logic... Try this..

 

 

-----

The best solution is the one you find it by yourself
Message 6 of 7
(5,882 Views)

 Thank you all very much!  I'm not 100% clear on why/how this works.  But I've been able to modify it to what I need.  Thanks again!

0 Kudos
Message 7 of 7
(5,832 Views)