why do we need a resistor connected to the base of the transistor?

Apologies if my post came over as being dismissive of the OP. It was not intended that way. Having read all the replies, it was obvious that the OP was being given information that he did not need; indeed some posters were using the thread as a pedantist 'one upmanship'.
I was merely suggesting that he may find a clear and concise explanation elsewhere.
I came to this forum seeking specific arduino advice, but have chipped in with comments where I percieved they may be of some help. I'll think long and hard before sharing my thoughts in the future.
As far as my 'posting score' is concerned, I really couldn't care less, having more important things to worry about!