From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM 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

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make that multiple boolean switches can impact on the run of a loop, via Arduino UNO?

Solved!
Go to solution

Hello! I'm a newbie in the LabView environment and I'm not familiarized to the functions the program offers. I'm making a simple Simon Says game using Arduino Uno through LINX. I've got stucked in the phase where it's the user's turn to repeat the shown sequence. Basically, the push buttons interact via "true" or "false" and I need the 4 "for" loops in order the 4 buttons to be detected in a certain lapse of time (I'm using a 100 ms duration of the loops so that the corresponding leds are lighted on briefly when pressed the push buttons), but I'm not sure if I'm handling properly the boolean results out of those "for" loops. Plus, I don't know how to stop the loop and exit it through multiple boolean conditions, if I connect them directly it would say that the "wired tunnel is undirected". 

I've also tried to handle the boolean responses with an "event" loop, but it seems that the event are only triggered if they're made through the "Front Panel" and they're not detected if using the Arduino Uno.

I'm attaching my VI, thanks in advance!

0 Kudos
Message 1 of 6
(3,596 Views)

Yes, event are primarily for user interactions on the front panel, so just poll the booleans and deal with them. No event structure needed.

 

However, you have way too many stacked loops. I think all you really need is a single while loop and some state machine architecture. try it.

Message 2 of 6
(3,593 Views)

What do you mean by polling the booleans? I'm not sure how to take the boolean value out of the "for" loops correctly.

Also, I think you're right about combining the 4 loops in a single one, I guess it might simplificate things a bit, although it would still be a "for" loop - it's the only way I achieved to make the push buttons to light the leds, when using "while" loops I couldn't make it work, even when using the same "Read"-"Write" structure. 😞

 

EDIT: just noticed I had uploaded an older version of my VI, here I attach the latest one.

 

0 Kudos
Message 3 of 6
(3,566 Views)

What's the purpose of the inner FOR loops?

0 Kudos
Message 4 of 6
(3,541 Views)

The 4 inner loops are there to maintain the connection with the Arduino UNO - I've specified a duration of 100 ms so that when the push button is pulsed, the led is lighted up briefly, if I increase this duration, then the led is continuously illuminated, if I put it to zero, then in doesn't light on. It won't work for me if I change the "for" loops to "while"s.

What I need is:

-When the connection with the Arduino UNO is open, I need to be able to pulse the 4 push buttons in order to send the signals to the program, means that, pulsing a button both sends the signal and both lights up it's corresponding led. But, I don't know how to get that boolean value correctly out of the "for" loops.

-So, when the program receives the signal, it compares it with the corresponding element in the sequence(which is the array of random integers from 0 to 4). I need to do this with the 4 push buttons (4 colours) and hence I need to compare the boolean 4 four times, which leads to 4 specified conditions to break the loop, and I don't know how to do that.

0 Kudos
Message 5 of 6
(3,508 Views)
Solution

OK, I found a solution! Using "While" loops and combining them in one. I'm attaching my VI.

0 Kudos
Message 6 of 6
(3,501 Views)