Values for calculating PN2222A Base Resistor
The low-side switching of a load requiring a higher voltage (than \$V_{CC}\$) is ubiquitous and probably one of the first design problems anyone just learning electronics gets to experience (and succeed at.) There aren't "several" posts on the topic here (or elsewhere.) There are thousands of them.



One of the problems your question brings up is "finding the value" of \$\beta\$ or \$h_{FE}\$.

I guess the knee-jerk answer to this is that you should not be designing your circuit on the basis of a specific value, so finding one isn't the point. However, you do need to have an idea about the worst-case value to expect in practice if you buy and use a specific part number from a vendor. This may require you to look at datasheets from several vendors to make sure you have covered your bases, here.

The value may vary not only from manufacturer to manufacturer (though there does tend to be some consistency you have a right to expect), but it varies over temperature (sometimes, quite a lot) and it also varies depending upon the value of the collector current (or base current, depending on the point of view you want to apply.) This means you will often check for a chart that shows the variations over temperature and collector current. Or, at least, check the table of values and find an entry that specifically provides a value that covers the entire temperature range.

The above would be more about the case where the BJT is used in an analog circuit operating the BJT in its active region. Not so much about using it as a switch (in saturation.) The values given in the datasheet will be mostly those needed by someone looking at it for active mode circuitry to make sure they can drive the part properly. In your case, you care about the switch behavior. This can be easier, since this basically means you ignore all the values and pick one out of your hat.



For operating a BJT as a switch, common practice (datasheet not available) is to assume a value of \$\beta=10\$. There is experience behind this choice. Such a low value means that the base current will be rather high and this means that your driving circuitry (which might be an I/O pin and a resistor) will almost certainly put the BJT into saturation so that it operates like a switch. Whether or not it actually does so, depends on the BJT, the collector current, the temperature, etc. But it's usually a sure bet, these days, at least for small signal BJTs. High power BJTs (which can still rarely be found in small TO-92 packages such as the PHD13003C) such as found in TO-220 packages will often have lower active region values of \$\beta\$. But as it turns out, these also will tend to provide switching behavior when driven so that \$\beta=10\$.

But even in these cases of operating a BJT as a switch, it is still worth grabbing a datasheet to make sure. Some power BJTs, for example, can have fairly high base current requirements as a percentage of their collector currents. So while \$\beta=10\$ may almost always work for you, there will be those times when it doesn't and you may kick yourself for not having checked.



I've talked about \$\beta\$ as if it is a thing of some kind. It's more like talking about cars with manual transmissions and discussing whether or not to drive the car in 4th gear or 1st gear. It's a choice. The car drives either way, under the right circumstances. But if you are towing a load, you may want to "shift down" into a lower gear. Your fuel economy will be terrible. But it will pull the load (probably.) So, kind of like that, you are making a choice about how to operate the BJT. And less about an intrinsic property of the BJT that is forcing you to do something.

If you operate the BJT in its active region (which your case is NOT), then you often wish that the value of \$\beta\to\infty\$ because you'd rather not have any parasitic drive current into the base, at all. So you may be looking at the value more to figure out how much the BJT will load down a prior drive circuit to make sure it can work right. In the car analogy, this may be more like wanting to drive fast and just wanting to know the highest gear you have available to you and what your wind resistance is likely to be so that you can work out the fuel economy. You hope for infinite fuel economy, but know that isn't possible and so you read the datasheet to see how good it might be. Usually, it is other parameters of the BJT that matter more and those will be why you pick one over another.

But to operate the BJT in saturation (your case), then you already know your fuel economy will be terrible. You are going to operate in the lowest gear because you need to tow a heavy load. That's a given. So here, you pick a low gear that you feel works and usually other BJT parameters don't matter so much. Mostly, you want to make sure the BJT can handle the collector current you need and that it can dissipate the power it will be expected to suffer while acting as a switch. (A saving grace here is that if it is really working close to how a switch operates, the voltage across the collector and emitter will be rather low and this is a good thing that helps a lot in lowering dissipation.)

So it is always worth looking at the datasheet (not only to verify your choice of \$\beta\$.) The datasheet will tell you about the collector current limitations, dissipation limitations, and also (of course) probably provide you with a "standard assumption" for \$\beta\$, regarding operating it as a switch.



Here are some datasheets for NPN BJTs (low side switches):


PN2222A
PHD13003C
TIP41


I'll walk though the first one. You hopefully can then apply similar ideas and walk yourself through the others on your own. So load it up.

On the first page you can see:



For the "A" device, \$V_{CEO}=40\:\textrm{V}\$. This is a maximum rating and it means that you can't use it for switching a load that requires more than that voltage. You should stay (well) under that value, if possible. In your case, no problem. You are talking about only \$12\:\textrm{V}\$, which is just fine.

Also, notice:



The maximum collector current is \$600\:\textrm{mA}\$. Your value is less. That's good. But this doesn't mean you are safe, yet. This is just a cursory check to make sure you didn't exceed a maximum specification here.

Now jump to Figure 11.



Above, you can see there is a note saying \$V_{BE(sat)}@\frac{I_C}{I_B}=10\$. This is a huge clue to you in using this device as a switch. They have taken the time to draw out a curve with \$\beta=\frac{I_C}{I_B}=10\$ and labeled it with "(sat)", too. This can be taken as a confirmation that using \$\beta=10\$ is "normal" for this device and it supports such an assumption when using this device as a switch. That's clue #1.

Now jump to Figure 4.



What a convenience! They actually include a curve for \$I_C=150\:\textrm{mA}\$, which is very close to the value you want. That's very nice. Now, look at the shape of the curve. The x-axis is the base current. The y-axis is the value of \$V_{CE}\$. Lower values of \$V_{CE}\$ are what you want in a switch. You can see that it kind of plateaus out at around \$100\:\textrm{mV}\$? This means that if you operate it with a base current of \$5\:\textrm{mA}\$ to \$10\:\textrm{mA}\$, then it will be working like a switch. Keep in mind, though, that these are going to be typical values and they will apply only at \$25^\circ\textrm{C}\$. If you jump up to Figure 3, not included in my reply here, you can see that the value of \$\beta\$ goes down at lower temperatures (perhaps about half as good at \$-55^\circ\textrm{C}\$.) So this means you should probably use at least \$I_B=10\:\textrm{mA}\$. If you work this out, that's \$\beta=\frac{150\:\textrm{mA}}{10\:\textrm{mA}}=15\$.

And now you can see why \$\beta=10\$ is usually taken as a safe bet here.



Once you've established a level of comfort about some value of \$\beta\$, you can then easily work out the needed drive current for your switch and then set about to make sure you achieve it.

In the first case, using a PN2222A, we've already established some possible parameters. You will need to supply at least \$10\:\textrm{mA}\$ to the base. You must now verify that your I/O pin can supply that much. And if so, what is the likely output voltage when high and supplying that current. Let's say that it can but that it can only output \$4\:\textrm{V}\$. (You really need to learn how to read datasheets on CPUs to find this.) I happen to know that using an estimated \$100\:\Omega\$ for the output resistance might be reasonable. If so, then \$10\:\textrm{mA}\cdot 100\:\Omega=1\:\textrm{V}\$ as the voltage drop. And that gets me to \$4\:\textrm{V}\$. From the above Figure 11, I can also see that \$V_{BE}\ge 860\:\textrm{mV}\$, typically. Rounded, this is \$V_{BE}= 900\:\textrm{mV}\$. So this means I'll have to drop about \$3.1\:\textrm{V}\$ across the resistor. So the resistor value is \$\frac{3.1\:\textrm{V}}{10\:\textrm{mA}}=310\:\Omega\$. A nearby, lower, value would be \$270\:\Omega\$. So again, assuming your I/O can handle it, you might try that resistor value.

One more thing. Power. The power dissipated by the PN2222A will be \$900\:\textrm{mV}\cdot 10\:\textrm{mA}+100\:\textrm{mV}\cdot 160\:\textrm{mA}=25\:\textrm{mW}\$.

Back on the first page of the PN2222A datasheet, find this:



Multiply this TO-92 package thermal resistance of \$200\:\frac{^\circ\textrm{C}}{\textrm{W}}\$ by the above dissipation and you find that the rise in temperature will be \$5^\circ\textrm{C}\$. Which is fine.



Now go apply these ideas to the other two datasheets I included above and see how all this holds up.