Can digitalWrite be used in Global or Setup?

Generally speaking, executable code must be inside a function.