Bug in delay function

        else if (550<=switching_delay<=1200)
...
     else if (205<=switching_delay<=500)
...
        else if (26<=switching_delay<=200)

A bug in delay () you say?
Check your C syntax

(Did you seriously think the problem was with delay() ? )

Hint - true (aka 1) and false (aka 0) are always less than 1200, or 500 or 200.