LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LED timed on

Hi, 

 

For a project I want to turn an LED on for 5 seconds with a switch on the high raise of the switch. So when the switch is turned on the led goes on for 5 seconds and than turns off. The switch could stay on that may not make a difference. When the switch is turned off again on then on the LED should turn on for 5 seconds again. So basically the LED should turn on 5 seconds every time on the high raise of the switch on. Can someone help me with this problem?

 

Thanks already!

0 Kudos
Message 1 of 3
(469 Views)

Hi Aaron,

 


@AaronDW100 wrote:

For a project I want to turn an LED on for 5 seconds with a switch on the high raise of the switch. So when the switch is turned on the led goes on for 5 seconds and than turns off.


Take a look at the ElapsedTime ExpressVI, it will help you a lot!

 


@AaronDW100 wrote:

When the switch is turned off again on then on the LED should turn on for 5 seconds again. So basically the LED should turn on 5 seconds every time on the high raise of the switch on.


So the LED should turn on only when the switch turns ON or also when the switch goes OFF?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(452 Views)

@AaronDW100 wrote:

For a project I want to turn an LED on for 5 seconds with a switch on the high raise of the switch. So when the switch is turned on the led goes on for 5 seconds and than turns off. The switch could stay on that may not make a difference. When the switch is turned off again on then on the LED should turn on for 5 seconds again. So basically the LED should turn on 5 seconds every time on the high raise of the switch on. Can someone help me with this problem?!


Are you talking about virtual switches and LEDs on the LabVIEW front panel or real switches and LEDs on a circuit connected to your computer in some way? I assume if the users constantly turns the switch on and off, the LED will stay on forever.

 

Either way, LabVIEW does not really care where values are coming from and going to, so the main code logic will be the same.

 

So start with a virtual implementation to keep things simple. What have you tried so far? I am sure your teacher already talked about all needed components, so look at your class notes first.

 

I would do as follows:

 

  • Place a switch control (make sure it has the desired mechanical action) and an LED indicator on the front panel.
  • Place a while loop with a reasonable wait on the diagram.
  • Place the terminals of your controls and indicators inside the loop.
  • Implement your required logic. Thinks about how it should work, the try a few approaches until things fall in place.
  • As a bonus (and for easier debugging), add a numeric indicator that displays how long the LEDs has been ON since the last F>T transition. 
  • Properly done, the code would probably fit on a postage stamp 😄

 

0 Kudos
Message 3 of 3
(410 Views)