06-30-2023 10:11 AM
So I would like to make leds blink x amount of times based on my numeric value inputs. So let's say if my input is 2, the led should go ON and OFF 2 times, Input = 3>>>> Led = ON and OFF 3x, and so on.
The only time I am able to achieve blinking is when the input (numbers) are the same as shown below, but if for example, I input 8 and 7, there's no blinking. In brief, the only time there is blinking is when the inputs are the same. How do I fix this? I would like to achieve blinking when inputs are not the same as well.
Solved! Go to Solution.
06-30-2023 10:45 AM
I won't give you the answer, but I will show you how troubleshoot it yourself. On the block diagram, click the lightbulb to go into highlighted execution mode. Then tell us why it isn't working.
06-30-2023 10:46 AM
Your code is full of glaring beginner mistakes.
06-30-2023 11:19 AM
06-30-2023 12:10 PM
Thanks Mr. Altenbach for pinpointing what I was doing wrong. The modified code is exactly what I was trying to do.
Thanks @Bilko, I really spent some time trying to find out what I was doing. I used that highlight execution.
06-30-2023 12:24 PM - edited 06-30-2023 12:26 PM
@Mr.Altenbach! I have an after question for you. I'm over here trying to understand your code. It is great and that's exactly what I want to achieve. Thanks again! but I would like to understand what you did for self improvement or maybe someone else as well.
I'm running the code and place the probes as shown below. I input 100 for third led and the probe clearly reads "FALSE" as you can see below, but the counting keep going. How do you explain that? What's the logic behind it?
06-30-2023 03:46 PM
@GRCK5000 wrote:
What's the logic behind it?
Your FOR loops executes so fast that all you see is the value from the last iteration when the code pauses for 100ms before going to the next iteration of the while loop. All other probe values inside the FOR loop last only nanoseconds and there obviously is no way to see that. You could change the last of the controls to a high number and it should be mostly true when counting. Use execution highlighting to slow down the code if you want to debug the others.
(Note that there is a tiny race condition, because if you change one of the controls, there is a small, but nonzero, probability that the change is undone when the local variable is written. See if you can fix that. 😄 )