Trouble adapting Speed code (Reed Switch)