From Thursday, May 23rd (05:00 PM CDT) through Friday, April 24th (1:30 AM 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 Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling LED with Switch

Solved!
Go to solution

Hello Engineers, 

 

I am new to Labview, so please be patient with me 🙂 

 

In this project, I am using one switch to turn LED On/Off. 

I want to keep the LED On with one press and stays On when I release the switch, but when I press the switch the second time, I want the LED to turn off and stays off. 

 

I did the design, but the only way that I could do it with is using for loop with specific length (the length of the for loop such as 10 iterations) when the case structure is true. 

 

I attached the file and picture of the hardware which is only one switch and one LED. 

 

Any improving idea would be appreciate it. 

 

Thank you in advance 

Download All
0 Kudos
Message 1 of 5
(3,400 Views)

A FOR loop that runs as fast as it can is not a timing device in any form. Look in the timing palette instead.

 

You probably only need to write to a Digital Write port when the value changes. No need to write the same value over and over.

 

Your code makes little sense. I would recommend to do a few more tutorials, look at the shipping examples, and then design it all as a simple state machine.

0 Kudos
Message 2 of 5
(3,367 Views)
Solution
Accepted by Eisa_Alyaqoub

See if this can give you some ideas....

 

 

altenbach_0-1584548532321.png

 

Message 3 of 5
(3,363 Views)

Thank you so much altenbach, this is just what I am looking for. 

 

Could you please explain how dose this Vi work ? 

 

Really appreciate it 

0 Kudos
Message 4 of 5
(3,334 Views)

@Eisa_Alyaqoub wrote:

Could you please explain how dose this Vi work ? 


There's not much to explain. You can right-click any element and launch the help. Place probes and run in execution highlighting to watch what happens. Do you understand some of it? Do you have a specific question?

0 Kudos
Message 5 of 5
(3,328 Views)