Basic variable declaration issue

Compiler is giving me a " 'delayPeriod' was not declared in this scope" error message. I thought I was supposed to initialize variables, esp. constants, in the setup section. I feel like I missing something huge here.

=====================

void setup() {
// Define input pins
const int lhInput = 1;
const int rhInput = 2;

// Turn all 7-seg display7 to output
for(int i = 4; i <= 12; i++){
pinMode(i, OUTPUT);
}

// RH switch
pinMode(rhInput, INPUT);
// LH switch
pinMode(lhInput, INPUT);

// delay and # of LED pulses
int delayPeriod = 250;
int pulses = 6;

// switch-state variables, initialized to false (no button presses)
boolean lhState = LOW;
boolean rhState = LOW;

}

void loop() {
// read switch state
if(digitalRead(1) == HIGH && digitalRead(2) == LOW){
lhBlink(delayPeriod, pulses);
}
else{
digitalWrite(8, HIGH);
delay(delayPeriod*5);
digitalWrite(8, LOW);
delay(delayPeriod);
}
}

void lhBlink(int delayPeriod, int pulses){
for(int i = 0; i <= pulses; i++){
//int x = 4;
//x++;
digitalWrite(8, HIGH);
delay(delayPeriod);
digitalWrite(8, LOW);
delay(delayPeriod);
}
}

Variables declared inside setup() are not visible outside setup(). Study variable scope.

In C variables are only valid in the scope they were declared in. Have a look at the example and play with it a bit. Print the values, so you can understand the differences.

int globalVariable = 0;

void setup()
{
int localVariable1 = 0;

localVariable1++; // this is valid

localVariable2++; // this is not valid

globalVariable++;  // this is valid too

for(int i = 0; i <= pulses; i++)
{
// i is only valid inside the for loop 

}

i++; // not valid, i no longer exists

} 


void loop()
{
int localVariable2 = 0;
static int staticVariable = 0;

localVariable1++; // this is not valid

localVariable2++; // this is valid, but variable will be deleted every time loop finishes

globalVariable++;  // this is valid too

staticVariable++;  // this is valid, but variable keeps value from loop to loop


}

The setup function is for code you only want to run once at the beginning.

The loop is called over and over again.

They are still simple C functions and variables/objects you need in both need to be global.

A tutorial on scope.

Had a feeling it was something that basic. It could've been really easy to be snarky about it, but you guys offered something constructive. Really appreciate it. Nice community.