From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I make LED turn ON and OFF based my numeric value input ? For instance, if I input 5, I would like LED to turn ON and OFF 5 times.

Solved!
Go to solution

So If I input 2, I would like the LED to go ON and OFF 2 times. 3 > 3 times, and so on. I tried, but failed. 

Can someone help?

See my attached code. 

0 Kudos
Message 1 of 12
(1,108 Views)

When does the count get reset?  Is there supposed to be a button to start the blinking?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 12
(1,090 Views)

Initially, the LED will be OFF.  So let's say I input number "1", I should expect the LED to turn ON then OFF once. If I input 100, I should expect the LED to turn ON and OFF 100 times. So there is no start button to start blinking. My input is the trigger basically.

Feel free to suggest too. I'm open for suggestions. 

0 Kudos
Message 3 of 12
(1,081 Views)
Solution
Accepted by topic author GRCK5000

This is what I came up with.  I used the Is Value Changed.vim to detect the input changing and perform the reset.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 4 of 12
(1,051 Views)

Thanks crossrulz!!! It works as expected. 

0 Kudos
Message 5 of 12
(1,037 Views)

Can't see paul's idea due to VI version, but here's mine.

 

snippy.png

Message 7 of 12
(963 Views)

@GRCK5000 wrote:

Initially, the LED will be OFF.  So let's say I input number "1", I should expect the LED to turn ON then OFF once. If I input 100, I should expect the LED to turn ON and OFF 100 times. So there is no start button to start blinking. My input is the trigger basically.

Feel free to suggest too. I'm open for suggestions. 


You need to be significantly more detailed in the requirements.

 

  • What should be the blinking rate? (should the on time be the same as the off time during blinking?
  • What should happen if the number is changed while it is still blinking from the previous input? SHould the control be disabled during blinking?
  • If you enter 5 and it blinks five times and then you enter 10, should it do five additional blinks or 10? What if the new number is less that the previous value?
  • Why do you have a pointless feedback node instead of doing the comparison before the case structure?
  • etc.

 

 

 

 

0 Kudos
Message 9 of 12
(870 Views)
Solution
Accepted by topic author GRCK5000

I don't think you need any case structures, here's one possibility:

 

altenbach_0-1686369548907.png

 

Message 10 of 12
(865 Views)