LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

control three lights to turn on randomly

Within my program I need to turn one of three lights on in no particular sequence (random selection). I tried to use the "random function" but it doesn't do the job (maybe the way I'm using it. I just need to have one of the three lights light during the sequence of the program. Help please!
0 Kudos
Message 1 of 9
(2,808 Views)
Can you attach a copy of your code?
********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 2 of 9
(2,802 Views)
Let's assume that your three lights are a 1D boolean array. The random function outputs a number between 0 and 1, so we'll take the result, multiply by 3 and round to -infinity so you get 0,1 or 2. Use "Replace Array Subset" - wire this number into the index and T into the value.

___________________
Try to take over the world!
0 Kudos
Message 3 of 9
(2,792 Views)
Hi
As Spaceman suggests, best choice is to post your code.
There are lots of ways to turn on one out of three lights in a random way.
If that is your only requirement, one way is as attached. ( just a quick example)

Cheers
Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
0 Kudos
Message 4 of 9
(2,790 Views)
0 Kudos
Message 5 of 9
(2,771 Views)
0 Kudos
Message 6 of 9
(2,770 Views)
0 Kudos
Message 7 of 9
(2,771 Views)
Sorry to be a bother, but in the program I sent earlier I was also wondering where I can configure the "physical channel" to be single ended instead of differential. Whenever I run it it appears( looking at the "analog input data) that it thinks it's a differential input.

One more:-) After I run the program how do I clear the status of the light back to zero so they all turn off before the next start?

All your assistance and help is greatly appreciated.
0 Kudos
Message 8 of 9
(2,752 Views)
Good question!

On the DAQmx Create Channel vi, there is a input named "Input Terminal Configuration." Right click on this input, and choose Create Constant. Than choose the needed configuration.

good luck,
Anuj D.
0 Kudos
Message 9 of 9
(2,730 Views)