Calling Functions in a program - error with not defined in scope while Globalvar

I am calling functions in a program that I have defined and declared.

For some reason I am getting errors, only on certain functions, although they are all declared and called using the same syntax.

Attached is my code.

Any help / guidance appreciated.

finalprojectadjustedatschool.ino (10.5 KB)

b3y0nd:
I am calling functions in a program that I have defined and declared.

For some reason I am getting errors, only on certain functions, although they are all declared and called using the same syntax.

And which functions are failing is a secret? We're supposed to guess? Is there a prize?

Steve

attached was the code.

thought maybe download and compile?

finalprojectadjustedatschool:174:23: error: 'potMeasure' was not declared in this scope

 int adjustLightAmount(potMeasure) // function returning pwmIncrease, which is used with counter to illiminate the lights

                       ^

finalprojectadjustedatschool:195:18: error: 'loopCounter' was not declared in this scope

 int adjustLights(loopCounter)

                  ^

finalprojectadjustedatschool:174:33: error: redefinition of 'int adjustLightAmount'

 int adjustLightAmount(potMeasure) // function returning pwmIncrease, which is used with counter to illiminate the lights

                                 ^

C:\Users\Adam\Desktop\finalprojectadjustedatschool\finalprojectadjustedatschool.ino:174:5: note: 'int adjustLightAmount' previously defined here

 int adjustLightAmount(potMeasure) // function returning pwmIncrease, which is used with counter to illiminate the lights

     ^

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

[\code]

Is it too much trouble to post the error messages?

Several of your function prototypes do not have correct syntax. Some do not have return values they claim to provide.

www.arduino.cc/en/Reference/FunctionDeclaration

There are many other compiling errors as well. Make sure you scroll up the error lists and fix them from the top down. You have some capitalization errors.

b3y0nd:
attached was the code.

thought maybe download and compile?

Sure, if we were the ones asking for free help. But, I’m pretty sure that’s you.

gfvalvo:
Sure, if we were the ones asking for free help. But, I'm pretty sure that's you.

Didn't mean it like that.

Wasn't sure of communication protocols based on the code. Wasn't sure if we had 100's of line of code how to go about asking for help about it either.

The most effective way to get help when your program is large is to post an MCVE. Not many people are inclined to wade through 100s of lines of unrelated and messy code. Trim things down and post something that demonstrates the problem and nothing more.

3 clicks. :slight_smile:

Arduino: 1.8.5 (Linux), Board: "Arduino Nano, ATmega328P (Old Bootloader)"

DS18x20:174: error: redefinition of 'int adjustLightAmount'
 int adjustLightAmount(potMeasure) // function returning pwmIncrease, which is used with counter to illiminate the lights
                                 ^
Multiple libraries were found for "Servo.h"
 Used: /home/jca/sketchbook/libraries/Servo
 Not used: /home/jca/arduino-1.8.5/libraries/Servo
/tmp/arduino_modified_sketch_282878/DS18x20.ino:174:5: note: 'int adjustLightAmount' previously declared here
 int adjustLightAmount(potMeasure) // function returning pwmIncrease, which is used with counter to illiminate the lights
     ^
exit status 1
redefinition of 'int adjustLightAmount'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Outsider...what 3 clicks?

tisk tisk tisk?

So I was able to "debug" the coding to allow for an upload.

Now, I am having difficulties with the start of the program.
I am trying to start the program, one time operation, and wait for the "start" button to be pressed after the instructions have been read.
However, my loop is iterating, and although visually in the serial monitor I can see the "Start of the start program function", it does not hold for the pushing of the button to start the program.

Do I need to move the flashing lights to the setup phase of the coding to run once, instead of in the loop...but I feel as though I should be able to control that process with no problem, even if in the loop.

void startProgram()
{
  Serial.println("Start of the start program function");
  currentMillis=millis();
  previousMillis=currentMillis;
  digitalWrite(redP1, 255);
  digitalWrite(redP2, 0);
  digitalWrite(redP3, 255);
  delay(200);
  digitalWrite(redP1, 0);
  digitalWrite(redP2, 255);
  digitalWrite(redP3, 0);
  delay(200);
  digitalWrite(redP1, 255);
  digitalWrite(redP2, 0);
  digitalWrite(redP3, 255);
  delay(200);
  digitalWrite(redP1, 0);
  digitalWrite(redP2, 255);
  digitalWrite(redP3, 0);
  delay(200);
  digitalWrite(redP1, 255);
  digitalWrite(redP2, 0);
  digitalWrite(redP3, 255);
  delay(200);
  digitalWrite(redP1, 0);
  digitalWrite(redP2, 255);
  digitalWrite(redP3, 0);
  delay(200);
  digitalWrite(redP1, 255);
  digitalWrite(redP2, 0);
  digitalWrite(redP3, 255);
  delay(200);
  digitalWrite(redP1, 0);
  digitalWrite(redP2, 255);
  digitalWrite(redP3, 0);
  delay(200);
//all red lights off
  digitalWrite(redP1, 0);
  digitalWrite(redP2, 0);
  digitalWrite(redP3, 0);
  digitalWrite(gP, HIGH);
// green light for start + push button reading
  Serial.println("Welcome to the shift simulator.");
  Serial.println("Instructions:");
  Serial.println("There are 3 RED lights, measuring the gas on throttle.");
  Serial.println("The green light indicates shift point.");
  Serial.println("The blue light indicates a good shift.  The yellow, a bad shift.");
  Serial.println("The round instrument creates audio depending on good shifts or bad shifts.");
  Serial.println("The button closest to round instrument is the button to shift. Press this when green LED lit.");
  Serial.println("Turning the POT adjusts the amount of throttle.  Use this to lite the RED LEDs slower or faster.");
  Serial.println("Remember, there must be little throttle while green LED lit and pressing the shift button.");
  Serial.println("Holding the POT at lowest point for 1.25 seconds will shift into reverse.");
  Serial.println("Pressing the button closest to the lights will start the game.");
 // startButton();              
}
//button to start running the program
void startButton()
{
  do
  {
  Serial.println("in the startButton function");
  Serial.println(buttonState);
  buttonState = digitalRead(pushButton);
  Serial.println(buttonState);
  }while(buttonState == prevbuttonState);
}
[\code]