04-30-2013 08:43 PM - edited 04-30-2013 08:45 PM
HI,
I'm trying to convert an arduino code to labV. I understand that the equivalent to an if statement is a case structure, but apparently I don't understand it very well. I made the program but it didn't work. I provided samples of the program in labV and arduino. Any help will be appreciated.
04-30-2013 09:10 PM - edited 04-30-2013 09:17 PM
The code for your 'if' looks ok to me. Maybe the issue is somewhere else -- do you need to initialize/configure your sensor?
Do some unit tests: Take out the sensor reading, range checking and case structure. Just write a constant value to the output. Are you able to make the LED light up?
P.S. For a simple case like yours, you can also use the Select function (http://zone.ni.com/reference/en-XX/help/371361F-01/glang/select/) instead of a case structure
04-30-2013 09:21 PM
Thanks for your quick response. I didnt set the false condition correctly, that was the problem. Now when the sensor read 0 or 1 the LED turn on, when it is not between that range it will turn off.
04-30-2013 09:40 PM
Hey danypag.
So, I saw your code. Nothing about your question itself, but I feel I can help you somehow.
How familiar are you to LabVIEW? I mean, your code is quite simple, but you can brush it up and make a more readable program and improve your projects in the future.
Writing your program from left to right, for example, is a good development practice.
If you want, check out this link: Getting Started with NI LabVIEW
Please don't get me wrong. I never meant to be rude, ok?
Hope this improve your knowledgement.
Regards!
04-30-2013 09:42 PM
Thanx joaopam, i'll consider it.
05-01-2013 10:07 AM
Now the only problem is to make a flag, I made a flag in the arduino program and now that is the only part in the lab view program that I can't figure out.
Any answer would be appreciated.
05-01-2013 07:16 PM
What will you be doing with the flag? How many values can the flag have? Typically a boolean would be used for a flag an probably passed from one iteration of the loop to the next via a shift register. Much more complex implementations are possible depending on your needs.
Lynn
05-02-2013 01:49 AM
@danypag wrote:
Thanx joaopam, i'll consider it.
Such a small program is a good candidate to try the Automatic cleanup function (ctrl+U) for a fast fix. I often need to modify the result to get satisfied, but it'll rearrange stuff to flow left-to-right and try to gather controls to the left and indicators to the right. It's a good reference.
/Y
05-02-2013 07:50 AM
Continued in this thread as well:http://forums.ni.com/t5/LabVIEW/How-to-make-a-flag/m-p/2410646#M745090