I had a program which was working perfectly till a while back and then I got an error which said "function not defined in scope". I then added all function declaration prototypes before the setup(). Now, a new error has popped up in the most basic of functions I have in my program.
Please help me understanding what is happening. The code is below -
void dashedLine()
{
for (int line = 110; line > 0; line--)
{
Serial.print('-');
}
Serial.println();
}
manor_royal:
Well you only posted a snippet, but if I put it below loop() and call it from setup() as below it compiles for me on a Uno.
Presumably you have more code
I do, I have close to 15 other functions. This code compiled perfectly till a while back and I didn't change anything in this function. I have the functions in different tabs. What seems to be the mistake?
You said there is a new error, but what is it? Is that the error in the title?
My code compiles and draws a line (after I remembered to add a Serial.begin anyway), and I'm not going to speculate about where your mistake is if you don't post the code.
manor_royal:
You said there is a new error, but what is it? Is that the error in the title?
My code compiles and draws a line (after I remembered to add a Serial.begin anyway), and I'm not going to speculate about where your mistake is if you don't post the code.
Yep. The new error is the one in the title. I did add Serial.begin in the setup().
And, about posting the whole code, I am not sure which parts are necessary. This is the function which is called in some places to make the serial output data more readable.
void setup()
{
Serial.begin(9600); //Initialize TX0/RX0
Serial1.begin(9600); //Initialize TX1/RX1
Serial.println("<CookSmart test program>");
Serial.println();
Serial.println("Initializing...");
Serial.println();
pinMode(LED, OUTPUT); //Declared LED as output
pinMode(encoderA, INPUT); pinMode(encoderB, INPUT); pinMode(encoderC, INPUT); pinMode(encoderD, INPUT); //Declared all encoders as input ports
pinMode(LSA, INPUT_PULLUP); pinMode(LSB, INPUT_PULLUP); pinMode(LSC, INPUT_PULLUP); pinMode(LSD, INPUT_PULLUP); //Declared all limit switches as input ports (used in-built pullup resistors)
pinMode(m11, OUTPUT); pinMode(m12, OUTPUT); pinMode(m21, OUTPUT); pinMode(m22, OUTPUT); pinMode(m31, OUTPUT); pinMode(m32, OUTPUT); pinMode(m41, OUTPUT); pinMode(m42, OUTPUT); //Declared all motor pins as output ports
sysReset(LSA, encoderA, m11, m12, 1, encMemA);
dashedLine();
}
abhir24:
I do, I have close to 15 other functions. This code compiled perfectly till a while back and I didn't change anything in this function. I have the functions in different tabs. What seems to be the mistake?
You changed something before the function, and that has confused the compiler.
Let's take the sentence "Batman scaled the building." It's pefectly fine. But if I put "Superman flew over " in front of it - accidentally missing "the tower, and " - not only is the sentence unparseable but it's not exactly clear where the problem is. The first thing you hit that can't be parsed is 'scaled' and that's where the compiler will report the error, even though the sentence 'Batman scaled the building' hasn't changed.
PaulMurrayCbr:
You changed something before the function, and that has confused the compiler.
Let's take the sentence "Batman scaled the building." It's pefectly fine. But if I put "Superman flew over " in front of it - accidentally missing "the tower, and " - not only is the sentence unparseable but it's not exactly clear where the problem is. The first thing you hit that can't be parsed is 'scaled' and that's where the compiler will report the error, even though the sentence 'Batman scaled the building' hasn't changed.
Thank you, Paul for the detailed explanation. I now understand where the error crept in!