Very nice presentation of your problem. Well done, and thanks.
(1) Check that your switch connects left to right when pressed and not top to bottom.
Remove switch - does LED go out.
Use a piece of wire. Does LED turn on?
(2) It appears that the problem is that the circuit they have given you is utterly and completely and inexplicably scrambled. It would be hard to have the circuit much wronger that that and still light the LED! It just MAY be sort of correct given several unlikely assumptions.
How can this be?
I so didn't believe what I was seeing that I checked several times.
2N2222 data sheet here
What transistor are YOU using?
What is the pinout.
Even if YOU are not using a 2N2222 they should be.
The circuit is wrong because:
They say 2n2222 so it should be NPN
It is normal to put the LED in the collector circuit but not essential.
If R3 is in collector then it should not go to V- power rail but to V+.
If we assume LED is in Emitter circuit then R1 must be in collector circuit and the transistor is being used as an "emitter follower". Not what you would usually do or for a beginner but say that's correct. And the pinout is backwards. Let's assume it is.
Then base should be being pulled +ve to turn on. It is.
They should have a pulldown on the bas to ground to turnthe transistor off - especially when used as an emitter follower. Connect another 10k from SW1/R1 junction to ground. Test . report.
BUT
Ensure transistor is CBE bottom to top as per 2N2222 datasheet or find what it really is.
Like this with different values, but I have added extra 10k from base to ground (a wise precaution).
I checkd 2N2222 data sheets from several manufacturers. ALL I found including metal can ones show transistor is CBE readingUP the breadboard as shown. (terminals 48-49-50) SO there is NO DOUBT that they have the circuit VERY WRONG as shown. Their C (terminal 48( goes via R3 to B- (ground). For an NPN transistor it should be B+ / +12v. etc. Build the circuit as I have suggested. It will work ;-). Transistor MAY be dead.
Datasheets
metal can
[TO18 & TO39 metal can both the same](metal can
)
All TO92 plastic seem to be ONSemi - several distributors:
Did they provide a proper circuit diagram?
If so please show it.
ONSemi TO92 plastic
Update:
Here is the book concerned .
(1) The transistor is reversed. Turn it around 180 degrees and their circuit is as they intended. Their basic data shows the transistor wrongly.
(2) And / But - the circuit is an emittee follower as it was obvious it would be if you "just" reversed the transistor. This is such an 'interesting' way to do things that it was hard to believe that it was intended. It was.
Their "rather interesting" circuit:
This probably comes down to one of two problems:
- You flipped some pins on the transistor. If I remember right, on a TIP41 the left pin is the base, the center the collector, and the right the emitter. This is when viewing with the black part of the package towards you and the pins down. Of course don't take my word for this. Check the datasheet.
- The GPIO1 pin isn't actually changing state. This is really easy to check. Put a voltmeter between GPIo1 and ground. It should be whatever the power supply voltage (usually 3.3 or 5 V) is when the LED is supposed to be on, and 0 V when its supposed to be off.
If the GPIO1 pin voltage is correct, then you almost certainly have the transistor wired up backwards, or it got blown out. However, a TIP41 is not so easy to blow out, so probably wired wrong.
If the GPIO1 pin voltage is stuck at the power supply, then you have a software problem.
A good way to check your circuit is to disconnect R2 from GPIO1. Then manually connect the left end of R2 to power and ground. The LED should be lit when it's connected to power, and not lit when connected to ground. If that's not the case, then the problem is with the transistor or how it's wired up.
Best Answer
I'm assuming your power supply is 5 volts, not 1 volt. As connected, the NPN transistor will attempt to short-circuit the power supply, which probably won't work. Try
simulate this circuit – Schematic created using CircuitLab