LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

how to create condition loop?

If you want to have the buzzer on only when the temperature is too high, you need to make it depend on the condition.  there are several ways to do this.  Probably the most simple is to use a case structure to contain all the code that is run when the temperature is too high (instead of doing the "?1:0" function, put it in the cast structure with everything that is dependent.

So, for the buzzer, you would output a non-zero freqency when the condition is true and a frequencey of zero when the condition is false.

Also remember that you should try to put all the Arduino VIs inline and only have once Close.vi to prevent race conditions in your code.

0 Kudos
Message 11 of 37
(1,812 Views)

hi, i had try use case structure for the temperature sensor, led and buzzer. But I used 2 close.vi. Can i ask how possible ways to put all in 1 close vi ? thank you so much!

0 Kudos
Message 12 of 37
(1,812 Views)

Fundamentally, you need to prevent the possibility of any two or more Arduino subVIs from being able to execute simultaneously.  The easiest [and most fundamental] way to do this is to create a data dependency between ALL Arduino subVIs.  With LIFA, this is usually done by having only one Arduino resource wire (the pink one) with no branching (see the image in reply post #1).  This requires you to put all Arduino subIVs in-line (creating the data dependency).  You can easily do this for the Tone Arduino subVI.

0 Kudos
Message 13 of 37
(1,812 Views)

hi wish to seek advice from you. I connect multi two temperature sensor in a line, yet both the result still not correct (the other buzzer on after another). Is it the circuit wrong? or I should use another arduino board. thank you so much.

0 Kudos
Message 14 of 37
(1,812 Views)

You are connecting the VIs in-line correctly but there are a couple other things that a incorrect.

If you read the description of Tone.vi, it says that you can only use it on a single pin at a time.  It explains what you need to do when you have more than one pin running it.  If you both of your sensors have the chance that they will both be over temp at the same time, you might need to consider a different approach.  I don't know much about the tone function but I'm guessing that you probably need to set the pin that you use for it as an output before using the tone.

The other thing is that you set pin 10 as an input and then try to write to it.  This is not what you want if you are using it to activate an LED.  You need to set the pin as an output (and for efficiency, set the mode outside the loop).  Writing to a pin set as an input actually sets the state of the internal pull-up resistor.

So, basically, you need to set the pin mode on any digital pin that you use prior to actually using it.  There are a few exceptions like I2C but those VIs do it automatically for you.

0 Kudos
Message 15 of 37
(1,812 Views)

Hi .. thank you for your reply!

Here another question, if i want to move the temperature data into microsoft excell for each second (for reference purpose), is this possible and how should I do? thank you!

0 Kudos
Message 16 of 37
(1,812 Views)

There is a VI that you can use to write to a spreadsheet file which will be be readable by Excel.

0 Kudos
Message 17 of 37
(1,812 Views)

Hiii, can i ask JPEG camera can work together with labview interface arduino? I just want to use the JPEG camera simply to watch the situation.

0 Kudos
Message 18 of 37
(1,812 Views)

hii, can help me on what's wrong with this circuit diagram as the result obtained bit wrong (temperature sometimes goes up suddenly then drop again), and it repeadtedly every few seconds.. or is it possible hardware circuit connection problem? thank you,,

0 Kudos
Message 19 of 37
(1,812 Views)

I don't see anything in the code that could cause that.  It is likely the sensor that you are using or possibly electrical noise.

Message 20 of 37
(1,812 Views)