LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

how to create condition loop?

I am new to Labview. I hope someone can help me to finish my final year project. I has been built two temperature sensor using arduino, xbee and labview. Then I plan to integrated by adding condition which when temperature exceed 40 degree celsius, buzzer and led will light up. My question is, how should I build condition loop in the while loop? Your help will be much appreciate.

0 Kudos
Message 1 of 37
(9,372 Views)

You should be able to simply use a conditional (greater than) and a case structure.  In the true case, put the code that lights up the LED and turns on the buzzer.

Also, you need to have all your Arduino VIs in a single line to prevent a race condition (i.e. each Arduino VI should use the resource wire that leaves the previous Arduino VI).  Therefore, there should only be a single instance of the Close.vi.  For example:

inline_example.png

Message 2 of 37
(4,270 Views)

thanks Nathan for your kidn reply.. I just try on it, I don't know how to lead the output of the result to the case structure.. can u show me?? thank you so much..

0 Kudos
Message 3 of 37
(4,270 Views)

Here is an example of what I was describing:

conditional.png

The "Volts to Celsius" subVI is simply what ever you need to convert between volts and celsius.

0 Kudos
Message 4 of 37
(4,270 Views)

thanks for reply.. i actually having problem on construct the led indicator circuit. From the led example, we control the led to switch on or off. I try modify it to become led indicator. any idea how to construct the circuit?

i try to use analog pin example, i set 5v. when more than 5v, the led will switch on automatic. but i get wrong result..

0 Kudos
Message 5 of 37
(4,270 Views)

For a basic LED you can simply use a digital pin.  Hundreds of websites can be found online that describe how to  wire LEDs.  There is also one on the Arduino website.

Also, if a digital pin will always be used as an output (or input), you should set the pin mode before the loop (it's much more efficient).  The other thing that I notice is the maximum analog input voltage  is only 5 volts so it will never exceed that (and you should avoid applying any more than that to the pin).

0 Kudos
Message 6 of 37
(4,270 Views)

i have been try on this circuit very long time i don't know where goes wrong. when temperature more than 32 degree celsius, the boolean function correctly, but the pin 13 in my arduino that i set didn't function well and light on all the time only. anywhere wrong in the circuit?

0 Kudos
Message 7 of 37
(4,270 Views)

You are probably having issues because you are setting the pin mode with a voltage (which is not good).  You need to set the pin mode before the loop starts because you never need it to change.

Also, the following two expressions are the same and will always give the same result.

check1.png

check2.png

Attached is how I would do it using the my previous suggestions.  Also, I've removed most of the options on Init.vi because they are the default values.

Message 8 of 37
(4,270 Views)

thank you so much!! i got it finally~

0 Kudos
Message 9 of 37
(4,270 Views)

sorry.. one more thing.. i want to put buzzer on the circuit, i use the arduino buzzer block. The result is not correct.. it switch on all time also.. how should I modify it? I have been try few times but not success. hope to see your reply..

0 Kudos
Message 10 of 37
(4,270 Views)