Here is a calculator for transistor base resistor values. Its IMPORTANT that you read the following.
Calculate the current you need to pass through the transistor when its on, that is your collector current.
The current gain, beta, Hfe, is a value you can find in the datasheet for the specific transistor. To calculate for the worst case use the minimum given Hfe value or the correct value for the collector current you need.
Vce voltage is the voltage over collector and emitter. A design guide not included in calculations for now.
Base voltage is the voltage that you use to drive the base of the transistor with.
Voltage drop is the Vbe(sat) value, you will get this from the datasheet looking at the graph for Vbe and Vce(sat) vs. collector current.
To insure to turn the transistor fully on, you can double the value for collector current, which will result in a base resistor value half of what this calculator gives you.
The examples are given for the highest collector current and worst case amplification factor, Hfe. Values for your circuit might vary, be sure to enter values for your own needs.
To calculate for a PNP transistor, enter negative numbers in collector current, base voltage and voltage drop.
Examples are given for NPN transistors 2N2222, 2N3055, 2N3904, BC547, TIP31, TIP31A, TIP31C, TIP41, TIP41A, TIP41C and PNP transistors 2N3906.