Hi there, am having an issue with a code that was working before.( Is attached),and I have a new modified version,(is attached as well) and am getting this error...
"NoLimits2RCS_DD_demo.ino: In function 'void loop()':
NoLimits2RCS_DD_demo:240: error: expected }' at end of input NoLimits2RCS_DD_demo:240: error: expected }' at end of input"
I have scanned the script multiple times and I cannot find the culprite that is causing the error.
Any help would be appreciated!
Thanks!
TTD03:
Hi there, am having an issue with a code that was working before.( Is attached),and I have a new modified version,(is attached as well) and am getting this error...
"NoLimits2RCS_DD_demo.ino: In function 'void loop()':
NoLimits2RCS_DD_demo:240: error: expected }' at end of input NoLimits2RCS_DD_demo:240: error: expected }' at end of input"
I have scanned the script multiple times and I cannot find the culprite that is causing the error.
Any help would be appreciated!
Thanks!
Like the Arduino?
It's an Arduino Leonardo connected on COM 3.
^^ I'm sorry to say I am not a very experienced coder, my friend wrote the script and I've been modifying the script ever since and it has been going alright. But in an instance like this, where my ability is not sufficient enough, I cannot figure it out. If you have found the problem, please share. Thank you.
^ Nope Robin, that issue got solved, completely different issue but same basic code.
When I started coding, I used this format. The opening and closing brackets are indented the same.
if (RestraintHX != RestraintPOS)
{ //If restraint button has moved...
delay (100); //Delay 100ms
if (RestraintPOS == LOW)
{ //If restraint button in close position...
RestraintHX = RestraintPOS;
} //Save new button value
else
{ //If restraint button in open position...
RestraintHX = RestraintPOS;
} //Save new button value
}
^^ I see you grabbed that from the original version which worked.
What is there now is this.
if (RestraintHX != RestraintPOS)
{ //If restraint button has moved...
delay (100); //Delay 100ms
if (RestraintPOS == LOW){ //If restraint button in close position...
RestraintHX = RestraintPOS;} //Save new button value
else{ //If restraint button in open position...
RestraintHX = RestraintPOS;} //Save new button value
}
Is this the part I messed up and not seeing it? Or is it something else that I missed?
@UKHeliBob: I use this now. But there are "helpers" now that highlight the matching opening or closing bracket if you select one. That was not available when Moses and I were sitting around the burning bush learning C with TurboC v1.0.
if (RestraintHX != RestraintPOS) { //If restraint button has moved...
delay (100); //Delay 100ms
if (RestraintPOS == LOW) { //If restraint button in close position...
RestraintHX = RestraintPOS;
} //Save new button value
else { //If restraint button in open position...
RestraintHX = RestraintPOS;
} //Save new button value
}
What is wrong with yours is you can't see the matching opening and closing brackets, and you are missing at least one.
Here is an example of what I recommend for you:
void function()
{
if(first if)
{
if(embedded if)
{
}
else // this indent matches the embedded if, and so do the following brackets
{
}
}
else // this indent matches first if and the following brackets do also
{
}
} // this is the closing bracket for the function
Damn, so easy, end of the code, was missing closing brackets, now the code works, how could I have missed that before
Edit 1:
I decided to start with my original version again and do the same modifications and be more careful about brackets, sure enough, did my changes, not 1 error. Turns out I had deleted 4-5 brackets while modifying the first time.
Edit 2:
Another question:
If you take a look in the Original Version.ino file and look at this part (Near line 190)
Why are there 3 closing brackets? I understand the 2 inner closing brackets but the last and most outer closing bracket specifically on line 202, I can't figure out what that closing bracket is closing. I tried the highlighting thing where you highlight one bracket and then the other highlights, but it is no where to be found. Any help is appreciated, thanks everyone, you guys rock!
Ctrl T is the IDE autoformat tool and If you use it frequently
and you miss a curly brace.. This message will show just above the compiler output window.
Autoformat failed; Too Many 'Right' / 'Left' Curly Braces.
left is the opening one and right is the closing curly brace..
@UKHeliBob: I still use that "brace on its own line" format if working with complex code. My web client example has the braces on their own line for ease of reading and checking for mismatched braces. http://playground.arduino.cc/Code/WebClient