compile error: 'connectedOn' was not declared in this scope

First of all read the sticky thread at the top of the programming questions forum.

Second, use code tags.

Third:

digitalWrite(connectedOn, LOW);

Where do you declare 'connectedOn', I don't see it anywhere, so how is the compiler supposed to compile the above line.

You have however made a global variable called 'connectedON'. Notice the difference? (hint: N != n)