constant for delay

Hi,

I'm trying to make some led light walk like on Kit.

I'm trying to use a constant for the delay so when I have to change the interval I don't have to change a large number of delay values.

This is the code so far but compiling this already gives trouble.

void setup() 
{ 
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);  
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  const int val = 30;
} 

void loop()
{
  digitalWrite(2, HIGH);
  delay (val);
}

After compiling I'm told "'val' was not declared in this scope". I think I just did???

Anybody know how to do it?

Thanks,

First, please use the button when posting code :)

Declare the constant outside of any function. This way it has 'global scope' and can be referred to in all functions.

They way you defined 'val', it is only in scope inside of the function setup(). Do what Alpha told you to change that.

Thanks,

Now it works!