For clarity, which Arduino board are you using? And, do you have any other Arduino boards handy? I've got a clone Uno that refuses to work for specific scenarios, but is fine for others. Took me ages to figure that out.
As another experiment with the gear you have, try using pins 14-19 (A0 - A5) instead of pin 9.