@tmtoronto
You seem to have 2 things going on
-
Error - Expected Declaration before '}' token error
-
Error - No Such file or Directory, even though you absolutely added the library.
so, clearly you are new to this stuff as these are beginner mistakes.
Instead of telling you the answer (which i'm sure others will do anyway) and then you'll have duplicate answers , let me show you what i do .
Problem 1 - it's called "BALANCING BRACES"
so the } thing. which is called a BRACE is the issue
You've put too many or too little in
Look at this code
void setup (){}
void loop(){}
// These are Balanced Braces
//Although you will generally see the "BARE MINIMUM" sketch to look like this
void setup (){
}
void loop(){
}
This can get confusing
so instead, when starting a sketch, Start like this...
void setup ()
{
}
void loop()
{
}
See how this is much clearer and you don't need to search for the braces.
ALWAYS have them on the left side of the screen.
the problem you are having is when this happens
void setup ()
{
}
void loop()
{
}
} // See this extra brace ? Notice it doesn't have an opening brace
so let me show you what i would do with your code
-
I'd make a copy of it that i can mess with
-
I would start with the deepest level braces and remove their contents
and when i find an opening and closing brace , i would delete them and their contents.
the idea is... if you have balanced your braces and then you delete all your code bit by bit
you will end up with the bare minimum sketch
let's see what happens when i do that to your code
void setup()
{ //Opens void Setup
servo1.attach(9); // attaches the servo on pin 9 to the servo object
servo2.attach(10); // attaches the servo on pin 9 to the servo object
// initialize the switch pin as an input:
pinMode(toolSwitch, INPUT); // tool change switch
digitalWrite(toolSwitch, HIGH); // turn on internal pull up
pinMode(solenoid, OUTPUT);
digitalWrite(solenoid, LOW);
} // Closes void Setup
THIS IS BALANCED
Now let's look at the loop Function
ERROR 1
if (pos > 119) // if pos is greater than 119 degree angle
// angle must be greater than max angleVal
{
digitalWrite(solenoid, HIGH); // turn on valve
delay(500);
servo1.write(179); //move servo1 to 179 degree angle
servo2.write(0); //move servo2 to 0 degree angle
delay(500);
servo1.write(angleVal); //move servo1 to start angle
servo2.write(angleVal2); //move servo2 to start angle
delay(500);
servo1.write(179); //move servo1 to 179 degree angle
servo2.write(0); //move servo2 to 0 degree angle
delay(500);
servo1.write(angleVal); //move servo1 to start angle
servo2.write(angleVal2); //move servo2 to start angle
delay(500);
servo1.write(179); //move servo1 to 179 degree angle
servo2.write(0); //move servo2 to 0 degree angle
delay(500);
digitalWrite(solenoid, LOW); // turn off solenoid valve
servo1.write(118); //move servo1 to 120 degree angle
servo2.write(60); //move servo2 to 60 degree angle
delay(1000);
if (pos >= 118)
; // if pos is greater than or equal to 118
digitalWrite(solenoid, LOW); // turn off solenoid valve
}
THIS IS INCORRECT
if (pos >= 118)
; // if pos is greater than or equal to 118
IT SHOULD BE LIKE THIS..
if (pos >= 118);
Moving forward..
Your Loop function was reduced to this
void loop()
{ //Opens void loop
else
{ Opens else 1
} //closes else 1
}// Closes void loop
Meaning...
YOUR BRACES ARE BALANCED
it seems like you just need to fix that first issue with the semicolon
Error 2 -
when you have included a library and it still says i'ts missing
Check the installation locations.
You may think arduino is using the my documents location when in fact it's using
the AppData Location. so it may exist in the MyDocuments location but if Arduino
is looking at the AppData location and it's not there then that's why you are getting the message.