Go Down

Topic: "was not declared in this scop" error (Read 1 time) previous topic - next topic


What dose this mean?

Getting it when I try and upload this code

Code: [Select]
// CountDownTest Joe Pardue 8/15/09

int seconds = 59;
int minutes = 59;     // Inititialise actual values for h,m,s

void setup () {
 // begin the serial communication

void loop () {

   seconds = seconds - 1;  // decrement the seconds
   tick = 0;               // reset the tick flag
   if (seconds < 0){       // If a minute has passed
     seconds = 59 ;         // Send seconds up to 59
     minutes = minutes - 1; // decrement the minutes

   delay(1000); // wait a second


You didn't post the whole error - you should have said " In function 'void loop()':
error: 'tick' was not declared in this scope"

You have a line which says

Code: [Select]
tick = 0;               // reset the tick flag

You never initialised this variable - you did for the variables "seconds" and "minutes".

Either initialise the variable (int tick =0;), or seeing as how you don't actually use the variable tick, just delete the above line from your code.


Your absolutely right, I understand the error now, missed the "In function 'void loop()':"  ;D


Btw, your code won't implement an accurate clock. All the code, not only delay(), will take some time to execute, especially Serial.print[ln]() calls. So the constant delay of 1000 ms won't work. You can use millis() to calculate more accurate delay-time.


Thank you very much for that, Im trying to change the code to print onto 4 7-segment LEDs (but not having much luck)

But I guess I will still need to use millis() when i finally work it out, so thank you!

Go Up