Expected declaration before '}' token

i keep getting this. please help as you finally got it working.

C:\Users\jbyno\AppData\Local\Temp.arduinoIDE-unsaved202468-140000-hjv78s.3qau\sketch_jul8a\sketch_jul8a.ino:45:1: error: expected declaration before '}' token
}
^

exit status 1

Compilation error: expected declaration before '}' token

@jbynorth95 - You should start your own topic with the subject title "expected declaration before '}' token" In your new topic, post your sketch so the solution can be shown to you.

Seriously need help. cant get this code to verify!

void loop() {
#include <ServoEasing.h>

ServoEasing servoTop;
ServoEasing servoBottom;

const int action_pin = 2;
int location = 31;

// Adjust these values if necessary
int bottom_closed = 107;
int top_closed = 167;
int bottom_open = 20;
int top_open = 20;

pinMode(action_pin, INPUT_PULLUP);
servoTop.attach(9);
servoBottom.attach(10);
setSpeedForAllServos(190);
servoTop.setEasingType(EASE_CUBIC_IN_OUT);
servoBottom.setEasingType(EASE_CUBIC_IN_OUT);
synchronizeAllServosStartAndWaitForAllServosToStop();

int proximity = digitalRead(action_pin);
if (proximity == LOW) {
if (location > bottom_open) {
servoTop.setEaseTo(top_open);
servoBottom.setEaseTo(bottom_open);
synchronizeAllServosStartAndWaitForAllServosToStop();
location = bottom_open;
delay(600);
} else
servoTop.setEaseTo(top_closed);
servoBottom.setEaseTo(bottom_closed);
synchronizeAllServosStartAndWaitForAllServosToStop();
location = bottom_closed;
delay(600);
}

Attached files are in general not appreciated unless they are too big to add in a post.

I'm sure you can do far better. Use code tags as described in How to get the best out of this forum.

Please edit your post, select all code and click the <CODE/> button. Next save your post.

Code tags make your code easier to read, easier to copy and the forum software will display it correctly.


If the code you presented is the full code, I suggest that you start from scratch; possibly even by starting to learn a bit about the coding in the IDE. You're missing e.g. a setup function, a #include does not go in a function (loop()) and possibly some other things. There is also a closing } missing.

I suggest that you have a look at the examples that come with the library that you use.

That is incorrect. Please post your code in code tags

In my experience the easiest way to tidy up the code and add the code tags is as follows

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

@jbynorth95

Topic split from another topic. Please do not add your own questions to the end of other people's topics.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Please show your full code using code tags

where is the setup() function ?
why does the loop opens before the #include ?
Are brackets matching ? indent the code...

you seriously need to read How to get the best out of this forum and then post accordingly (including code with code tags and necessary documentation for your ask like your exact circuit and power supply, links to components etc).

@jbynorth95 , do not cross-post, it wastes peoples time. I've merged your two topics.

And now please add code tags to your post with that contain code.

It looks like your original code document was an HTML page which uses column formatting that puts code like this out of order... for example... your "code" has "loop()" at the very top, with configuration information inside "loop()" and is missing the "setup()" function. Would you show the source of the original code?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.