mpick
Followed your link to RS, typically they have no link to a datasheet or Hfe values or anything to figure out what resistor you need.
Yes, I can go to another online supplier and look it up, but after reading the bad reviews on RS about their packaging of the wrong parts, just order them from DigiKey, or one of the others listed here http://www.findchips.com/.
The explanation that works best for me to figure the value can be found herehttp://www.rason.org/Projects/transwit/transwit.htm.
Didn't check your code, lots of others here are way more adept at spotting mistakes.
TomJ