Error message "...was not declared in this scope"

I am new to Arduino and I keep getting the following two error messages:

"scoreboard:96: error: 'update_scoreboard' was not declared in this scope

update_scoreboard, // 004


scoreboard:97: error: 'test_mode' was not declared in this scope

test_mode, // 005"

I have no idea what this means or how I can fix the problem. Can anyone help me through this?

Thank you in advance.

I have no idea what this means or how I can fix the problem.

You could show us your sketch.
Use </> icon in the posting menu to attach the code.

messengerCallbackFunction messengerCallbacks[] =
  update_scoreboard,            // 004
  test_mode,                    // 005

This is the section to which the error relates.

What are you trying to do?

The error you get is because you haven't declared the variables update_scoreboard and test_mode.

you declare a variable by doing something like:

int a = 0; // in that case the variable a is declared as an integer with value 0

You can use a variable only once you declared it.

If you don't understand anything of what I am saying, you need to take a look at a c++ tutorial before you continue.

Ok thanks, I will go give that a look.

Basically, the project I am looking at is to create a scoreboard for my local cricket club. I obtained this code from another club who did something similar and set up a "how to" website. I've contacted them about the issue but as yet I've had no reply.

The Arduino will send the signals to the shifters to set the correct numbers to be displayed on the scoreboard.

I assume that the variables here would be that "update_scoreboard" would be to update the board with the correct numbers and "test mode" would be to check that the scoreboard is working?

I'd suggest that the missing items are functions, not variables.
If only we could see the code {sigh}

Sorry, as I say, I am new to this... Here is the code:

// Command overview
// 4,BatAScore,Total,BatBScore,Wickets,Overs,Target# //display a score on the board
// 5# //test mode

// Wiring layout
// shifter set 1, pins 2 (SRCK),3 (SERIN),4 (RCK) --> Batsman 1 score, total, batsman b score, 9 characters (e.g. 001200050)
// shifter set 2, pins 5 (SRCK),6 (SERIN),7 (RCK) --> wickets, overs, target, 6 characters (e.g. 240240)

// Shifter library available from
#include <ShifterStr.h>

// CmdMessenger library available from
#include <CmdMessenger.h>

// Base64 library available from
#include <Base64.h>

// Streaming4 library available from
#include <Streaming.h>

// set up the field seperators and command seperators.
char field_separator = ',';
char command_separator = '#';

// set up the chharacter arrays we will use later
char batsmanAScore[4] = { '\0' };
char batsmanBScore[4] = { '\0' };
char total[4] = { '\0' };
char wickets[2] = { '\0' };
char overs[3] = { '\0' };
char target[4] = { '\0' };

// set up the headings
char batAHeading[] = "Batsman A Score:";
char batBHeading[] = "Batsman B Score:";
char totalHeading[] = "Total Score:";
char oversHeading[] = "Overs:";
char wicketsHeading[] = "Wickets:";
char targetHeading[] = "Target:";
char batAandTotal[] = "Batsman A Score, Total and Batsman B Score:";
char wicketsOversandTarget[] = "Wickets, Overs and Target:";

// Attach a new CmdMessenger object to the default Serial port
CmdMessenger cmdMessenger = CmdMessenger(Serial, field_separator, command_separator);

// dreamcat4 default
// ------------------ C M D  L I S T I N G ( T X / R X ) ---------------------

// We can define up to a default of 50 cmds total, including both directions (send + recieve)
// and including also the first 4 default command codes for the generic error handling.
// If you run out of message slots, then just increase the value of MAXCALLBACKS in CmdMessenger.h

// Commands we send from the Arduino to be received on the PC
  kCOMM_ERROR    = 000, // Lets Arduino report serial port comm error back to the PC (only works for some comm errors)
  kACK           = 001, // Arduino acknowledges cmd was received
  kARDUINO_READY = 002, // After opening the comm port, send this cmd 02 from PC to check arduino is ready
  kERR           = 003, // Arduino reports badly formatted cmd, or cmd not recognised

  // Now we can define many more 'send' commands, coming from the arduino -> the PC, eg
  // For the above commands, we just call cmdMessenger.sendCmd() anywhere we want in our Arduino program.

  kSEND_CMDS_END, // Must not delete this line

// Commands we send from the PC and want to recieve on the Arduino.
// We must define a callback function in our Arduino program for each entry in the list below vv.
// They start at the address kSEND_CMDS_END defined ^^ above as 004
messengerCallbackFunction messengerCallbacks[] =
  update_scoreboard,            // 004
  test_mode,                    // 005
// Its also possible (above ^^) to implement some symetric commands, when both the Arduino and
// PC / host are using each other's same command numbers. However we recommend only to do this if you
// really have the exact same messages going in both directions. Then specify the integers (with '=')

// set up 3 groups of shifters
Shifter shifterSet1(9, 2, 3, 4);  //Bat A, Total, Bat B controlled by pins 2,3 and 4
Shifter shifterSet2(6, 5, 6, 7);  //Wickets, Overs and Target controlled by pins 5,6 and 7

void update_scoreboard()
  while ( cmdMessenger.available() )

    // lets assume we always get the correctly formatted string
    // its lazy, but should be ok

    char buf[4] = { '\0' };
    char tempString[10] = { '\0' };

    // Batsman A Score
    cmdMessenger.copyStringArg(buf, 4);
    strcpy(batsmanAScore, buf);
    cmdMessenger.sendCmd(kACK, batAHeading);
    cmdMessenger.sendCmd(kACK, batsmanAScore);

    // Total Score
    memset(buf, '\0', 4);
    cmdMessenger.copyStringArg(buf, 4);
    strcpy(total, buf);
    cmdMessenger.sendCmd(kACK, totalHeading);
    cmdMessenger.sendCmd(kACK, total);

    // Batsman B Score
    memset(buf, '\0', 4);
    cmdMessenger.copyStringArg(buf, 4);
    strcpy(batsmanBScore, buf);
    strcpy(tempString, batsmanAScore);
    strcat(tempString, total);
    strcat(tempString, batsmanBScore);
    cmdMessenger.sendCmd(kACK, batBHeading);
    cmdMessenger.sendCmd(kACK, batsmanBScore);
    cmdMessenger.sendCmd(kACK, batAandTotal);
    cmdMessenger.sendCmd(kACK, tempString);

    // Wickets
    memset(buf, '\0', 4);
    cmdMessenger.copyStringArg(buf, 4);
    strcpy(wickets, buf);
    cmdMessenger.sendCmd(kACK, wicketsHeading);
    cmdMessenger.sendCmd(kACK, wickets);

    // Overs
    memset(buf, '\0', 4);
    cmdMessenger.copyStringArg(buf, 4);
    strcpy(overs, buf);
    cmdMessenger.sendCmd(kACK, oversHeading);
    cmdMessenger.sendCmd(kACK, overs);

    // Target
    memset(buf, '\0', 4);
    memset(tempString, '\0', 10);
    cmdMessenger.copyStringArg(buf, 4);
    strcpy(target, buf);
    strcpy(tempString, wickets);
    strcat(tempString, overs);
    strcat(tempString, target);
    cmdMessenger.sendCmd(kACK, targetHeading);
    cmdMessenger.sendCmd(kACK, target);
    cmdMessenger.sendCmd(kACK, wicketsOversandTarget);
    cmdMessenger.sendCmd(kACK, tempString);

void test_mode()
  char buf[] = { "Test Mode" };
  cmdMessenger.sendCmd(kACK, buf);

// default dreamcat4 stuff

// ------------------ D E F A U L T  C A L L B A C K S -----------------------

void arduino_ready()
  // In response to ping. We just send a throw-away Acknowledgement to say "im alive"
  cmdMessenger.sendCmd(kACK, "Arduino ready");

void unknownCmd()
  // Default response for unknown commands and corrupt messages
  cmdMessenger.sendCmd(kERR, "Unknown command");

// ------------------ E N D  C A L L B A C K  M E T H O D S ------------------

// ------------------ S E T U P ----------------------------------------------

void attach_callbacks(messengerCallbackFunction* callbacks)
  int i = 0;
  int offset = kSEND_CMDS_END;
  while (callbacks[i])
    cmdMessenger.attach(offset + i, callbacks[i]);

void setup()
  // Listen on serial connection for messages from the pc
  Serial.begin(57600); // Arduino Uno, Mega, with AT8u2 USB

  // cmdMessenger.discard_LF_CR(); // Useful if your terminal appends CR/LF, and you wish to remove them
  cmdMessenger.printLfCr();   // Make output more readable whilst debugging in Arduino Serial Monitor

  // Attach default / generic callback methods
  cmdMessenger.attach(kARDUINO_READY, arduino_ready);

  // Attach my application's user-defined callback methods


  // Set the displays to 000 on boot

// ------------------ M A I N ( ) --------------------------------------------

// Timeout handling
long timeoutInterval = 2000; // 2 seconds
long previousMillis = 0;
int counter = 0;

void timeout()
  // blink
  if (counter % 2)
    digitalWrite(13, HIGH);
    digitalWrite(13, LOW);
  counter ++;

void loop()

  // Process incoming serial data, if any

  // handle timeout function, if any
  if (  millis() - previousMillis > timeoutInterval )
    previousMillis = millis();

void update_scoreboard();
void test_mode();

messengerCallbackFunction messengerCallbacks[] =
  update_scoreboard,            // 004
  test_mode,                    // 005

Thank you.

That appears to have solved the problem!