LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling blinking rate of LED by three push buttons

Hi, I am trying to control the blinking rate of LED by three push buttons. When I press P1, LED blinking rate is 1s, for P2 - 0.5s and for P3 - 0.25s.

 

Problems occurs only when P2 is pressed, I cannot change to P1 while P2 is pressed. 

 

Please anybody can solve me that problem!

 

Thank you!

0 Kudos
Message 1 of 11
(4,503 Views)

Is this homework?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 11
(4,472 Views)

Yes, it is. 

0 Kudos
Message 3 of 11
(4,455 Views)

Could you save it in LV 2013 so i can see what you're doing and maybe give you some hints?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 11
(4,453 Views)

Throw away what you have and start over.  That is a nightmare of case structures and while loops all embedded inside of each other.

 

A user would need to figure out the magic combination stop button presses and pushbutton presses to get the code to work the way they would expect.

 

Your master stop button should have a mechanical action of Latch when Released as opposed to the switch action you have now.

 

You can do this with a single while loop, a single case structure, and also a set of radio buttons.

Message 5 of 11
(4,438 Views)

@absias wrote:

Hi, I am trying to control the blinking rate of LED by three push buttons. When I press P1, LED blinking rate is 1s, for P2 - 0.5s and for P3 - 0.25s.

 

Problems occurs only when P2 is pressed, I cannot change to P1 while P2 is pressed. 

 


Your problem is actually more than changing from P2 to P1.  The third requirement of P3 blinking at .25s wasn't met and once you do add that wait time you will find that the problem is actually going from a higher P to a lower P.

 

I agree with RavensFan that you should probably start over but you are technically not far off from the solution.  With your current set up you can actually get the behavior you want by placing a sequence structure in every true case that will have the while loop in the first frame and the two case structures in the next frame.

 

Edit:  I should clear up that technically my solution is incorrect.  If you are at a higher P and select the lower P in between when the VI checks the case structures in the second frame but before it starts the next loop you will not see expected behavior.

Matt J | National Instruments | CLA
0 Kudos
Message 6 of 11
(4,417 Views)

Hello guys, thank you for all of you, the tips you gave me were very useful.

 

Here is the new vi. Everything is working, 

 

Just want to ask one more question, if I want to put timer interrupt, for ex. if switch one is pressed and LED blinking each second, then after 10 seconds interrupt takes action and stops the blinking. If during this 10 seconds switch 2 is pressed, then reset the interrupt timer back to 10 second.

 

Thank you for all the replies, really appreciate it.

0 Kudos
Message 7 of 11
(4,365 Views)

Hi Absias,

 

on your VI: it is using way too much code (and local variables)...

 

See attachment!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 11
(4,355 Views)

Dear GerdW,

 

Thank you, really good method. I just start learning labview, and I am already fell in low with it. 

 

Thanks

0 Kudos
Message 9 of 11
(4,345 Views)

Hi again,

 

Can anybody please check this vi.

 

I put a timer, so that after 10 seconds LED turned off in any case. But when SW0 is on, and after 4 seconds I press SW1 and then I press SW0 back, timer counts only 6 seconds and resets, but I want 10 seconds after I press any switch. What should I include?

 

Thank you!

0 Kudos
Message 10 of 11
(4,331 Views)