LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Difficulty with adding extra LED

Solved!
Go to solution

Hello all,

 

Hope someone can help me with this. I have some difficulty with adding an extra led in the program. There is already one led in the program which burn on a random time between 3 and 7 seconds. Now I want to add one extra led which also burn on random time, but not at the same time when the other led is also burning. Till now I only can manage it with both leds burning at the same time. The program is a reaction timer, see attachment. 

Thanks in advance!

0 Kudos
Message 1 of 8
(2,488 Views)

Could you be a little more specific about what you're trying to do?  Do you want to add a second Start button, or just a second LED?  Under what conditions should that second LED turn on?  Do you want the new LED to turn on ONLY if the other LED is off, or you want it to run independently such that sometimes both LEDs might be on at the same time?

 

Can you attach code showing what you've tried, instead of showing only your existing code?

0 Kudos
Message 2 of 8
(2,475 Views)

I just want to add a second LED which runs independently of the first LED, so indeed sometimes they will burn at the same time. I tryed with an additional (copy) event structure and/or case structure, tryed with subVI butt it did not what I expected. Till now I only could let both LED's burn at the same time...

0 Kudos
Message 3 of 8
(2,470 Views)

It should come on with the start button and after that with the stop button, actually same as how the first LED is operated, but it should not continuously burn the same time as the first (green) LED

0 Kudos
Message 4 of 8
(2,468 Views)

Right now, when you push the Start button, it waits a random amount of time and then turns on the LED.  Let's call that time T1.  When the user pushes the Stop button, the LED turns off and reports the time since the LED turns on.  I don't understand how the second LED should work.  You want the second LED to turn on at some different random time, T2?  Does the user wait until both LEDs have turned on before pushing the Stop button, or only waits for whichever comes first?

 

I can think of a few possible solutions depending on what you want.  I think you'll need to do some math in the timeout case.  One option: after the first timeout occurs, calculate a new timeout time and use that for the second LED.  Another possibility is to use a short timeout period and inside it determine whether to turn on each LED.

0 Kudos
Message 5 of 8
(2,466 Views)

Ow yeah right I didn't told what's the purpose of the T2 LED, the T2 LED is a kind of distraction. You should only push the stop button when the T1 (excisting) LED is burning. So you don't have to wait for both LED's to burn to press stop. You press stop when the T1 LED is burning. 

I want to make it optional to choose for both LED's, for example with toggle switch. So normally it's only the T1 LED and when the toggle switch is true both led's come in play. Also when you press (wrong) when only the T2 LED is burning it should be saved in an array. But I don't know yet what I want the program should do..  But that's for later, first things first 😉

0 Kudos
Message 6 of 8
(2,463 Views)
Solution
Accepted by topic author Matt V

The absolute easiest way I can think of to do this is to add a second loop and use a notifier to communicate between the two.  When the user pushes the Start buttton, or the Stop button resets the timer, send a random number on the notifier to the second loop.  In the other loop, wait on the notifier.  Put the value received into a shift register and then use it as the timeout value for the next notification; when it times out, set the second boolean to true.  Something like the attached VI (I took out the calls to the DLL).

 

There are some other problems with your VI: there should be a way to exit it, and you never reset the array to 0 length.

0 Kudos
Message 7 of 8
(2,453 Views)

This is great! I couldn't think this myself. It looks easy, but I never worked with those components so I have to studie a bit to know exactly what it does and how it works. I know there are still some minor problems with the VI, I work on that today.

But thanks a lot!!

0 Kudos
Message 8 of 8
(2,440 Views)