Removing Serial.println() causes errors

For my second attempt with Arduino (Blink being the first), I tried combining the AnalogInput and BlinkWithoutDelay examples to make the blink speed controlled by a potentiometer. I got it working, and I had a Serial.println(interval); in there for debugging. Once I took it out, the blinking would start at the correct interval, then would quickly speed up and go constant-on (or a very small interval). With the attached code, can anybody help me? Thanks!

define potPin 2

define ledPin 13

float val = 0; float interval = 0; long previousMillis = 0; int value = LOW;

void setup() { pinMode(ledPin, OUTPUT); Serial.begin(9600); }

void loop() { //280-630 : Approxamate range of my pot val = analogRead(potPin); interval = long((((val)-270)/360)*1000); //Change the val to an interval, approx 0-1000 Serial.println(interval); //The debug line that, when removed, causes error if (millis() - previousMillis > interval) { previousMillis = millis();

if (value == LOW) value = HIGH; else value = LOW;

digitalWrite(ledPin, value); } }

Can't see what's wrong right off, but I'd be inclined to use "long" for "interval" and "val", instead of "float" (floats are generally very much slower than integer data types). This line:

 interval = long((((val)-270)/360)*1000);

could be replaced by a "map" call http://arduino.cc/en/Reference/Map

Yeah, I found map after posting this. They were float because integers/longs wouldn't work properly for some reason (you can tell I'm new to this). Anyways, I changed the setup to add in the Calibration example and used map for the interval, and now it works. Thanks for the reply