From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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 I can manipulate a 2D array of leds so that the LEDs light up in different ways ?

Solved!
Go to solution

Hi everyone, 

I have tried to understand Altenbach code but it is too hard for me, so I tried to do by myself. However this is what I get.

 

Should I add another for loop and a replace array?

 

 

0 Kudos
Message 11 of 16
(1,643 Views)

@TWRLK wrote:

Should I add another for loop and a replace array?

 


What is the purpose of the local variable? All you need is place the terminal in its place.

 

The result of your subtraction is sometimes a negative number.  Since there are no elements with negative indices, you won't get anything useful when that happens. Right?

 

Why are you wiring above the right inner shift register (creating a new tunnel) instead of across it?

0 Kudos
Message 12 of 16
(1,629 Views)

I corrected my code and it finally works.!!

 

Can you check it and tell me if I can improve it?

 

 

0 Kudos
Message 13 of 16
(1,577 Views)
Solution
Accepted by topic author TWRLK

@TWRLK wrote:

Can you check it and tell me if I can improve it?


You have way too much duplicate code. All your inner loops can be combined into one. All that differs are a few integer math parts and only these would go into a small inner case structure with four cases. There is also no need for local variables.

 

What's the point of all the hidden wires? Just to confuse the observer? Eliminate them. All you needs ot to wire out from the right-shift register. No need for a seperate output tunnel per loop.

 

Your diagram constants should be blue, not orange. Do you know why?

 

As mentioned, you should make the code scalable. Your diagram constants can be derived from the array size, so the code can adapt no matter what the size of the square input array is.

0 Kudos
Message 14 of 16
(1,572 Views)

Ok thanks for your advice, I will change my code...No, I do not know what is the difference between blue and orange variables. Can you tell me? 

0 Kudos
Message 15 of 16
(1,561 Views)

@TWRLK wrote:

Ok thanks for your advice, I will change my code...No, I do not know what is the difference between blue and orange variables. Can you tell me? 


it's the datatype. Blue wires are integers. You would right-click the diagram constant and select represetation...I32.

 

Also note that your math is incorrect. Sometimes toy are accessing the same element twice in a row. For example after replacing the top four elements, you only need to replace 3 elements going down, three elements going left, and two elements going up. etc.

0 Kudos
Message 16 of 16
(1,552 Views)