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: 

Connecting arduino to LED matrix/array

I don't where to start though

0 Kudos
Message 51 of 97
(1,379 Views)

It is useful to think about a project like this in two directions, often called top down and bottom up.

 

The top down thinking starts from the diagram I posted and breaks down each block into smaller pieces. The bottom up approach is probably a better description of what youhave done so far. You have implemented several small pieces but have done so in ways which tend to keep them from working well together.

 

For example your random numbers are generated outside the loop so the same values are used as long as the program is running. To allow an option to play another game without stopping the VI and starting it again the random generation needs to be inside the loop, possibly in an added state.

 

One way to implement a diagram like that is to have a loop for every decision diamond which has an output connected to an earlier part of the diagram. However, a program with nested loops can be very difficult to stop or to handle errors. Such programs can often be implemented in a state machine or Producer/Consumer architecture without nested loops.  The top down thinking will start by choosing an overall architecture which is well suited to the main behavior of the program.

 

Similarly, it is important to think very carefully about where to place the event structure in a program.  In your program pressing the play button more than once will lock up the front panel because the Initialize game state only executes once.  Programs with a lot of user-front panel interaction should almost always start from the Producer/Consumer (Events) design template.

 

Lynn

Message 52 of 97
(1,361 Views)

Should I start over?

0 Kudos
Message 53 of 97
(1,354 Views)

No. But I do recommend pausing to think through the design before trying to write more code. Some things will probably need to change. Others may only require small modifications. And even where large changes are required, it is likely that you can copy and paste chunks of what you have.

 

Lynn

Message 54 of 97
(1,350 Views)

Wait. Can we do one thing, work this out one at a time? Lets start with the random number generator, how can we fix that?

0 Kudos
Message 55 of 97
(1,397 Views)

Could you possibly show me how?

0 Kudos
Message 56 of 97
(1,394 Views)

OK.

 

How many different sets of random numbers will you need? To play one game, it appears you need one. So the answer depends on how many games will the user be permitted to play without stopping and restarting the VI.

 

If the answer is always 1, then the way you do it now could work. If the answer is >=1 and not definitiely known at the time you write the program, then you want the random number generation process to be inside the loop, possibly in the Initialize Game state or in a separate state.

 

If the generation is inside the loop, then the data needs to be in a shift register(s) to pass form one state to another.

 

If the number of lights to be guessed can ever change, then the generation needs to be done in a manner which is adaptable to various numbers. Consider an "Introductory" mode where only two lights are used to explain the process and make correct guesses fairly easy. Then an "Intermediate" mode with 4 lights and an "Improbable" mode with 5.  Think about how to do this with the only input to the random generation process being a mode selector.

 

Lynn

Message 57 of 97
(1,390 Views)

Ah I see can you show in a vi or pic

0 Kudos
Message 58 of 97
(1,388 Views)

but we have 5 different led lights

0 Kudos
Message 59 of 97
(1,382 Views)

yes we want it to greater than 1

 

0 Kudos
Message 60 of 97
(1,375 Views)