button ˝mode˝ on pin 2 is not working

off;

Should be:

off();

You should use ‘change in state’ instead of ‘level’ detection.

See example in IDE.

How is your switch wired?

S1, S2 or S3?