Arduino using pn2222 transistor as a switch11/24/2023 ![]() As mentioned in the question, I was using a button wired into an LCD shield. So the question is, why does the circuit work as expected for the LED, but not for the fan? Any help/suggestions will be greatly appreciated! I've tried different pins on the board, but always get the same result. But in my case, the current from the relevant digital pin to the transistor's base never goes higher than 1.4mA. My understanding is that an Arduino digital pin should easily supply this. Measuring the current from VIN (or the 5V pin) to base, I get 4mA, so my assumption is that 4mA is sufficient to saturate the base. If I take a wire directly from VIN or the 5V pin and touch it to base (through a resistor, of course), it does succeed in saturating the base, and the fan turns on. It does turn the LED on and off as expected, but the fan needs much more current than the LED. The problem that I have is that the Arduino's digital pin doesn't seem to be able to saturate the base, so not enough current passes through the transistor to power the fan. My expectation is that, when I press the button, the digital pin wired to the transistor's base will cause the transistor to close the circuit and turn the fan (and LED) on for five seconds. the relevant digital pin is switched from LOW to HIGH for a determined time in response to a button press recorded on A0.įor simplicity, I'm showing a separate button component in the diagram, but I'm actually using a button that's wired into an LCD shield. this resistor should be placed between gate output and LED or between LED and ground - either way is fine.I'm using a 2N2222 transistor as a low-side switch to turn a 5V computer fan on and off with an Arduino digital pin, which responds programmatically to a button press - i.e. for most LED diodes a good value is 200 ohms (more is also ok, it's just less bright). when output state is ON in these two examples, the only outcome here can be either burned transistor or burned LED, unless you have a limited current power supply which is low enough to not burn these elements. There should be current limiting resistor for the LED diode. An even better way is to use NAND gate and add a NOT gate to its output which also creates an AND gate. ![]() If done like in example, then the emitter resistor should be smaller (1k) or the base resistor should be larger - anyway, the resistors should be somewhere 10x size difference (base vs emitter) or more to ensure the output voltage stays low enough that the possible next logic gate input doesn't go ON when it shouldn't. Now this example may work, but it's not a good practice to do it like this. 1.43V voltage drop on emitter resistor which is also the output voltage in this example and this is not close to desired 0V for output in OFF state. Typical base-emitter voltage drop of saturated transistor is around 0.7V, so the remaining voltage (4.3V = 5V - 0.7V) is distributed on base resistor (10k) and emitter resistor (5k), which means approx. In the example above we can calculate approximate voltage drop: There can be a problem when only B input is active - when this happens, the "base-emitter" of the "B" transistor acts like a diode, so there is current flowing through emitter resistor (5k) creating a voltage drop. Nice tutorial, but there are a few things that I think should be mentioned here.ġ.) AND gate, also XOR and XNOR where AND gate is used. (As i mentioned before these are easy circuits, so on a breadboard I wont show them step-by-step) There is a small text and a gif for every logic gate. I will also show this circuits on the breadboard. I am going to show the logic gate's symbols, truth tables and schematics. When the base-emitter diode is turned on enough to be driven into saturation, the collector voltage with respect to the emitter may be near zero and can be used to construct gates for the TTL logic family. The use of transistors for the construction of logic gates depends upon their utility as fast switches. I think if you know a little bit about NPN transistors, you will be fine. These circuits are extremely easy to understand. What you need -A breadboard -A bunch of 5k and 10k resistors, and transistors -A LED You can use any NPN type transistor (for example 2N3904, BC547, BC548, BC549 etc.) These are basic circuits, so they can be improved (with diodes for reverse voltage protection, for example), or can be simplified (XOR, XNOR gates), but for start we will stick with these basic circuits. Hi guys, in this tutorial I will show you some NPN transistor based logic gates.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |