LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting the time interval for LEDs

hello I am new to labview, I am trying to do something simple, but made it a lot more complicated than it needs to be. I need turn on an LED and turn it off, but in random intervals, such as turn it on for 1 second, then turn it off for 2 seconds, then turn it on for 2 seconds, then turn it off for one second, so no real pattern. I need to do this to the LED for a minute, I tried a really convoluted method with a time target and case strictures, but I can only program that to activate in specific intervals, I am not able to set them. Any help will be greatly appreciated. Here is a VI of my convoluted method that didn't work.

0 Kudos
Message 1 of 10
(3,775 Views)

All you need is a single while loop and a state machine architecture.

 

Even simpler, generate the random wait time and invert the boolean after each iteration. Stop when 60 seconds have elapsed. (See attached)

0 Kudos
Message 2 of 10
(3,766 Views)

that is really close and a great solution, but I guess I should have been more clear. I still want to set what the wait time is, like I want to be able to set it to 2, then 3, then 1, then 3,then 2, then 1, my problem arose because the numbers were so random, not that I couldn't get random numbers.

0 Kudos
Message 3 of 10
(3,751 Views)

Not able to see your VI ( have LV9 ).

But if you say you want to set time Then how do you want to do it ?

Do you have any Particuler sequence that is already given

or you want to calculate it programatically  or based on previous state of LED ?

0 Kudos
Message 4 of 10
(3,738 Views)

@jdrum wrote:

that is really close and a great solution, but I guess I should have been more clear. I still want to set what the wait time is, like I want to be able to set it to 2, then 3, then 1, then 3,then 2, then 1, my problem arose because the numbers were so random, not that I couldn't get random numbers.


How do you want to set the various times then? You need a control that has N different times, one for each interval. Or do you read the times from a file?

 

Easiest would be to have an array of time intervals, then simply autoindex it on a FOR loop. The loop will stop automatically once the array runs out of elements. The rest would be similar to the code already posted.

 

0 Kudos
Message 5 of 10
(3,721 Views)

Okay, I took your advice, great advice by the way, but I'm trying to light up LED's with aduino, so I need to set my 3x4 matrix into a 1D matrix. I try, but I cannot get an entire row of the LED matrix to light up, only the first three, can you get it so the first row corresponds to the first three, the next row corresponds to the next three?

0 Kudos
Message 6 of 10
(3,689 Views)

Please attach your VI.

0 Kudos
Message 7 of 10
(3,687 Views)

sorry, I thought I attached it

0 Kudos
Message 8 of 10
(3,683 Views)

sorry, thought it was attached 

0 Kudos
Message 9 of 10
(3,669 Views)

You have not tried to implement altenbach's suggestion of autoindexing an array of delays.

 

The Reshape Array needs to be outside the for loop. You want to reshape the 3x4 2D array into a 12 element 1D array.  What you are doing is reshaping a 3 element 1D array into a 12 element 1D array. This results in the last nine elements always = zero.

 

The Arduino expects an 8-bit unsigned integer. So the data in the arrays should also be U8.

 

If the index to Replace Array Subset is negative or greater than the maximum index in the 2D array, it does nothing.  I am not sure exactly what you are trying to do with the array index manipulations so I did not try to fix it.  I added some indicators to show what is happening.

 

When using autoindexing on a for loop, do not also wire to N.

 

The Arduino Rseource wires and the error wires should be connected through the loop boundaries with shift registers, not tunnels, particularly not autoindexing tunnels.

 

I do not have an Arduino, so I used Diagram Disable structures to disable the Arduino VIs for testing without getting errors.

 

You seem to be allergic to straight wires. Actually the auto wiring tool is probably on and IT is allergic to straight wires.  I find it easier to understand a block diagram where the wires do not have excessive bends.

 

Lynn

0 Kudos
Message 10 of 10
(3,652 Views)