I'm currently working on a strobescope program using the millis() function.The reason I'm using millis() is because I want to have several LEDs flashing simultaneously in different frequencies(this part wasn't so hard).The program below is a simplified version of the program I'm working on, which is based on the "Blink without Delay" program introduced as an example in a tutorial. http://arduino.cc/en/Tutorial/BlinkWithoutDelay

What I want to do in the version below is to have the blinking frequency go down(or up) after going up(or down).This program is partially working, because the frequency goes down once, and then goes back up once, but after that the frequency keeps on going down.

// constants won't change. Used here to // set pin numbers:const int ledPin = 13; // the number of the LED pin

// Variables will change:int ledState = LOW; // ledState used to set the LEDlong previousMillis = 0; // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,// will quickly become a bigger number than can be stored in an int.long interval = 100; // interval at which to blink (milliseconds)

int i = 0; //using to countint up = 1; //using as a flag to indicate if the program to count up or down

In my understanding, this program should continuously make the frequency go up and down again and again, but for some reason it only does that once and keeps on going down after that.Can anyone explain why it does so, and are there any ways to solve that problem?