'value' was not declared in this scope error whilst multiplexing. (SOLVED)

Hello.

I am trying to multiplex a 2 digit 7 segment LED display, by calling functions with variables that determine whether the left digit is lit or the right digit is lit.

I am trying to do this as follows (very much simplified for posting):

int ZeroFunction(value){
  digitalWrite (led13, HIGH);
  digitalWrite (led12, LOW);
  digitalWrite (led11, HIGH);
  digitalWrite (led10, HIGH);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, HIGH);
  digitalWrite (led6, HIGH);
  if (value == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (value == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }
}

Then, by calling the function as follows I expect to be able to control which digit displays the value:

void loop() {
  
  int Zero;
  Zero = ZeroFunction(0);
  delay (1000);

However, I declare the variable (called "value") at the top before the void setup function, yet when compiling I get the error:

"'value' was not declared in this scope".

This error occurs on a line that is just used to int a constant used for an LED:

const int led10 = 10; // top right

Can anyone tell me what's going on?

Thanks a lot for your help, much appreciated.

Ari

Read the how to use this forum sticky.
Post code that will compile and shows your problem, there is too much unknown here you are holding back.

Sorry about that, here is the full code, although I'm afraid it won't compile:

const int led13 = 13; // top 
const int led12 = 12; // middle
const int led11 = 11; // top
const int led10 = 10; // top right
const int speaker9 = 9;
const int led8 = 8; // bottom right
const int led7 = 7; // bottom
const int led6 = 6; // bottom 
const int button5 = 5;
const int gnd4 = 4; // left ground
const int gnd3 = 3; // right ground

int buttonState = 0;
int iVariable = 0;
int digitDeterminingVariable = 0;

void setup() {                

  pinMode(led13, OUTPUT);
  pinMode(led12, OUTPUT);  
  pinMode(led11, OUTPUT);  
  pinMode(led10, OUTPUT);  
  pinMode(speaker9, OUTPUT);  
  pinMode(led8, OUTPUT);  
  pinMode(led7, OUTPUT);  
  pinMode(led6, OUTPUT);
  pinMode(button5, INPUT);     

}

int BlankFunction(){
  digitalWrite (led13, LOW);
  digitalWrite (led12, LOW);
  digitalWrite (led11, LOW);
  digitalWrite (led10, LOW);
  digitalWrite (led8, LOW);
  digitalWrite (led7, LOW);
  digitalWrite (led6, LOW);
  
}

int ZeroFunction(digitDeterminingVariable){
  digitalWrite (led13, HIGH);
  digitalWrite (led12, LOW);
  digitalWrite (led11, HIGH);
  digitalWrite (led10, HIGH);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, HIGH);
  digitalWrite (led6, HIGH);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }
}

int OneFunction(digitDeterminingVariable){
  
  digitalWrite (led13, LOW);
  digitalWrite (led12, LOW);
  digitalWrite (led11, LOW);
  digitalWrite (led10, HIGH);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, LOW);
  digitalWrite (led6, LOW);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }

}

int TwoFunction(digitDeterminingVariable){

  digitalWrite (led13, LOW);
  digitalWrite (led12, HIGH);
  digitalWrite (led11, HIGH);
  digitalWrite (led10, HIGH);
  digitalWrite (led8, LOW);
  digitalWrite (led7, HIGH);
  digitalWrite (led6, HIGH);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }
    
}

int ThreeFunction(digitDeterminingVariable){

  digitalWrite (led13, LOW);
  digitalWrite (led12, HIGH);
  digitalWrite (led11, HIGH);
  digitalWrite (led10, HIGH);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, HIGH);
  digitalWrite (led6, LOW);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }

}

int FourFunction(digitDeterminingVariable){

  digitalWrite (led13, HIGH);
  digitalWrite (led12, HIGH);
  digitalWrite (led11, LOW);
  digitalWrite (led10, HIGH);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, LOW);
  digitalWrite (led6, LOW);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }

}

int FiveFunction(digitDeterminingVariable){

  digitalWrite (led13, HIGH);
  digitalWrite (led12, HIGH);
  digitalWrite (led11, HIGH);
  digitalWrite (led10, LOW);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, HIGH);
  digitalWrite (led6, LOW);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }

}

int SixFunction(digitDeterminingVariable){

  digitalWrite (led13, HIGH);
  digitalWrite (led12, HIGH);
  digitalWrite (led11, HIGH);
  digitalWrite (led10, LOW);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, HIGH);
  digitalWrite (led6, HIGH);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }

}

int SevenFunction(digitDeterminingVariable){

  digitalWrite (led13, LOW);
  digitalWrite (led12, LOW);
  digitalWrite (led11, HIGH);
  digitalWrite (led10, HIGH);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, LOW);
  digitalWrite (led6, LOW);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }

}

int EightFunction(digitDeterminingVariable){

  digitalWrite (led13, HIGH);
  digitalWrite (led12, HIGH);
  digitalWrite (led11, HIGH);
  digitalWrite (led10, HIGH);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, HIGH);
  digitalWrite (led6, HIGH);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }

}

int NineFunction(digitDeterminingVariable){

  digitalWrite (led13, HIGH);
  digitalWrite (led12, HIGH);
  digitalWrite (led11, HIGH);
  digitalWrite (led10, HIGH);
  digitalWrite (led8, HIGH);
  digitalWrite (led7, HIGH);
  digitalWrite (led6, LOW);
  if (digitDeterminingVariable == 0) {
    digitalWrite (gnd4, LOW);
    digitalWrite (gnd3, HIGH);
  }
  else if (digitDeterminingVariable == 1) {
    digitalWrite (gnd4, HIGH);
    digitalWrite (gnd3, LOW);
  }

}


void loop() {
  
  int Zero;
  Zero = ZeroFunction(0);
  delay (1000);

  int One;
  One = OneFunction(1);
  delay (1000);
}

When I try to compile it gives me the following errors:

Looped_Proper_Multiplexing:5: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:6: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:7: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:8: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:9: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:10: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:11: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:12: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:13: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:14: error: 'digitDeterminingVariable' was not declared in this scope
Looped_Proper_Multiplexing:43: error: redefinition of 'int ZeroFunction'
Looped_Proper_Multiplexing:5: error: 'int ZeroFunction' previously defined here

Thanks very much for your help, but I've solved it myself - in fact the information that I gave you originally was quite sufficient. The error was in the declaration of the function, I wrote:

int ZeroFunction(value){
}

instead of

int ZeroFunction(int value){
}

Ari

Good on sorting it out but your initial information was not sufficient because it looked like a function definition not a variable one. It was out of context and so impossible to spot.