The memory location of lightVal? You seem to be calling it as a int inside the while which could be setting it as new rather than replace. Try it without the int inside the while
Hi Ryan What if i want to use a button to shift between 5 different cases and the cases should loop until the button i pressed again? Like first case is the AnalogInOutSerial, case 2 is Fade example and so on? I want the fade example to loop until the button is pressed and then it goes on to the next program. :)
In this situation, you would require two additional parts. The first, would be a button checking "if" statement. Each time the button is pressed, it will do one of two things: 1) if the current case value is less than 5, add 1 to the "switch" variable (to progress to the next case) or, 2) if the switch variable is currently the 5th case, set the "switch" variable back to 1 (to restart the loop).
+Piddy D Yes! Just don't define the variable within the while loop. Instead, define your variable before the void setup, and that should solve the problem. ;)
Nice Ryan. Good work. I am working on a project based on 2 sensors which work with one LED (one will turn it On and another one will turn it off, for 3000 times (without timers)). Dont know how to use switch-case for that outcome. Please help.
The memory location of lightVal?
You seem to be calling it as a int inside the while which could be setting it as new rather than replace. Try it without the int inside the while
Hi Ryan
What if i want to use a button to shift between 5 different cases and the cases should loop until the button i pressed again?
Like first case is the AnalogInOutSerial, case 2 is Fade example and so on?
I want the fade example to loop until the button is pressed and then it goes on to the next program. :)
In this situation, you would require two additional parts. The first, would be a button checking "if" statement. Each time the button is pressed, it will do one of two things: 1) if the current case value is less than 5, add 1 to the "switch" variable (to progress to the next case) or, 2) if the switch variable is currently the 5th case, set the "switch" variable back to 1 (to restart the loop).
Hi just wondering what the fix was for the While loop problem was as i have similar problem and i just can't figure it out
+Piddy D Yes! Just don't define the variable within the while loop. Instead, define your variable before the void setup, and that should solve the problem. ;)
Nice Ryan. Good work.
I am working on a project based on 2 sensors which work with one LED (one will turn it On and another one will turn it off, for 3000 times (without timers)). Dont know how to use switch-case for that outcome.
Please help.
So would be
lightVal = analogRead(lightPin);
Yep - you're probably right! Thanks!