Try adding this to your setup. pinMode(2, INPUT_PULLUP) If you still get no output, try a stronger external pullup on D2.
pinMode(2, INPUT_PULLUP)