Potentiometer +Delay

Hello, so i have been learning Arduino for a week now and i was just playing with some of the basic exapmles.

I tried to create fading RGB LED which cycles through RGB colors.
At the start of the program the LED is OFF.... It turns ON and cycle when i push a button...

I created a seperate function for the Potentiometer readings... the Value should define the Delay which i use in the Loop function....

Now when i push the button it works it takes the Delay value which was present. but when i try and turn the pot when the loop is running it doesnt change the delay and the printed ( in the monitor window) value is always the value taken when i pushed the button...

The code is attached.

Thank you

RGB_cbf_v3.ino (1.25 KB)

The trick is to read the potentiometer more often. There are two ways to do this. One is to read it on every pass through the for loops in loop(). The other (better) is to get rid of all for loops and delay()s, and use a state machine to determine what loop() should do on each iteration.

The first is easier; the second is better.

Thank you.
I sound like a noob...but what is a state machine ?

christizzz:
Thank you.
I sound like a noob...but what is a state machine ?

You'd sound less like a noob if you had a private chat with Mr. Google before posting.

touché