not declared in this scope

I'm a beginner with Arduino Uno.
and I'm studying with a book titled "Programming Arduino Getting Started with Sketches".

Below is the coding I referred.

int ledPin = 13;
int delayPeriod = 250;

void setup()
{
pinMode(ledPin, OUTPUT);
}

void loop()
{
for (int i = 0; i < 20; i ++)
{
flash();
}
delay(3000);
}

void flash()
{
digitalWrite(ledPin, HIGH);
delay(delayPeriod);
digitalWrite(ledPin, LOW);
delay(delayPeriod);
}

It's a simple coding to turn on and off the LED.
I uploaded this coding on my board via IDE 6.1.12 a few days ago.
and now I try again but the system said that 'flash' was not declared.
I didn't change anything of this coding.
but it was operated before but not now.
I don't know why and how to solve this problem.
Even on the book, the author declared all functions on the bottom of the programmings.

I searched on google but there was not accurate answer.
so I'm asking here.

Also I heard that Arduino include prototype declare so I can declare the function in anywhere.
then why doesn't it work now?

I think I didn't touch any settings of board or IDE...
please somebody help me.

I just pasted your code in my Arduino program. After compiling it i had no errors.
Can you copy your error and paste it here so i can check.

kingchakir:
I just pasted your code in my Arduino program. After compiling it i had no errors.
Can you copy your error and paste it here so i can check.

sure.
here it is.

C:\Users\h4bir\OneDrive\臾몄꽌\Arduino\programming_arduino_ed2-master\sketch_04_01\sketch_04_01.ino: In function 'void loop()':

sketch_04_01:14: error: 'flash' was not declared in this scope

exit status 1
'flash' was not declared in this scope

this makes me crazy.

Strange your code seems to work for me. :o
Screenshot - 239fc9b37b181cf895f33d7f68d3cc41 - Gyazo (screenshot of your working code)

int ledPin = 13;
int delayPeriod = 250;

void setup()
{
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  for (int i = 0; i < 20; i ++)
  {
    flash();
  }
  delay(3000);
}

void flash()
{
  digitalWrite(ledPin, HIGH);
  delay(delayPeriod);
  digitalWrite(ledPin, LOW);
  delay(delayPeriod);
}

I am not sure what causes this problem maybe restarting your pc/laptop?

kingchakir:
Strange your code seems to work for me. :o
Screenshot - 239fc9b37b181cf895f33d7f68d3cc41 - Gyazo (screenshot of your working code)

int ledPin = 13;

int delayPeriod = 250;

void setup()
{
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  for (int i = 0; i < 20; i ++)
  {
    flash();
  }
  delay(3000);
}

void flash()
{
  digitalWrite(ledPin, HIGH);
  delay(delayPeriod);
  digitalWrite(ledPin, LOW);
  delay(delayPeriod);
}




I am not sure what causes this problem maybe restarting your pc/laptop?

That's why I'm going crazy.
I have already tried re-installing IDE and rebooting my PC and Laptop both.....
but I can't still figure out..
and as I said, it worked before but it doesn't work now. huhuhu
what should I do now???

jaywhang90:
C:\Users\h4bir\OneDrive*臾몄꽌*\Arduino\programming_arduino_ed2-master\sketch_04_01\sketch_04_01.ino: In function 'void loop()':

Known bug: prototype generation fails in IDE 1.6.10 and later if the file path contains non-ASCII characters.

There is a fix waiting to be merged: Fix UTF8 filenames not being matched by gcc -e output parsing by facchinm · Pull Request #178 · arduino/arduino-builder · GitHub

#define A 3
#define B 2
#define C 6
#define D 8
#define E 7
#define F_SEG 4
#define G 5

// Pins driving common anodes
#define CA1 13
#define CA2 12

// Pins for A B C D E F G, in sequence
const int segs[7] = { A, B, C, D, E, F_SEG, G };

// Segments that make each number
const byte numbers[10] = { 0b1000000, 0b1111001, 0b0100100, 0b0110000, 0b0011001, 0b0010010,
0b0000010, 0b1111000, 0b0000000, 0b0010000 };
int btn = 3;
int hall_pin = 16;
int hall_state = 1;
int revolutions = 0;
float miles_in_inches = 63360;
float mph = 0.0;
float distance = 0.0;
float tire_diameter =10;
float k_ipm_2_mph;
int tire_circumference;
unsigned long last_fall = 0;
unsigned long last_interval = 0;

void setup() {

pinMode(A, OUTPUT);
pinMode(B, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(E, OUTPUT);
pinMode(F_SEG, OUTPUT);
pinMode(G, OUTPUT);
pinMode(CA1, OUTPUT);
pinMode(CA2, OUTPUT);
delay(500);
k_ipm_2_mph = 3600000 / miles_in_inches;
tire_circumference = tire_diameter*3.14159;
pinMode(btn, INPUT);
pinMode(hall_pin, INPUT);
LED.blink()
LED.print("01111001");
delay(1000);
}

void loop() {
int hall_val = digitalRead(hall_pin);
if (hall_state != hall_val && hall_val == LOW) {
revolutions++;
last_interval = millis()-last_fall;
last_fall = millis();

}
hall_state = hall_val;
updateSpeedAndDistance();
LED.print("hall");
LED.print(hall_state);
LED.print("Mph:");
LED.print(mph);
LED.print("Miles:");
LED.print(distance);

}

void updateSpeedAndDistance(){
distance = tire_circumference * revolutions;
distance /= miles_in_inches;
float ipm = tire_circumference / (float)last_interval;
mph = ipm * k_ipm_2_mph;
}

The full error message is

C:\Users\Bob\AppData\Local\Temp\arduino_modified_sketch_395264\sketch_jan06a.ino: In function 'void loop()':

sketch_jan06a:63: error: 'LED' was not declared in this scope

   LED.print("hall");

   ^

exit status 1
'LED' was not declared in this scope

The compiler does not lie. LED was not declared in that, or any other scope.

Was there perhaps meant to be a library included and an object named LED or is there a chunk of code missing to do with a 7 segment LED display ?

Where did you get the code ?

C:\Users\erturul\Documents\Arduino\sketch_nov21b\sketch_nov21b.ino: In function 'void loop()':

sketch_nov21b:26:25: error: 'blinkState' was not declared in this scope

oldBlinkState = blinkState; // remember for next time

^

sketch_nov21b:28:12: error: 'blinkState' was not declared in this scope

if (blinkState == LOW) { // change to LOW if your sensor is LOW when blinking

^

exit status 1
'blinkState' was not declared in this scope

Would it be too much to ask for you to post the full program that generated the error ?