// Sketch 4-01 (From the book :) )
int ledPin = 13;
int delayPeriod = 250;
void setup()
{
pinMode (ledPin, OUTPUT);
}
void loop()
{
flash(20, delayPeriod);
delay(3000);
}
void flash(int numFlashes, int d))
{
for (int i = 0; i < numFlashes; i ++)
{
digitalWrite(ledPin, HIGH);
delay(d);
digitalWrite(ledPin, LOW);
delay(d);
}
}
I’m following the process of this book but my IDE gives me the error “‘flash’ was not declared in this scope. Keep in mind, I’m new to programming and this is probably a basic error. Just trying to modify the blinking LED program.
You must place a declaration of the function
flashbefore it’s being used.Either place a prototype of the function before the
loopfunction, like this:Or you place the whole function definition before the
loopfunction.And by the way, you have a closing parenthesis to much in the function header. Which of these problems is the real culprit is hard to say without seeing the errors.