## NOT Gate Realization using BC 547 and Arduino Mega

by realfinetime  |  in transistor at  10:34

NOT Gate realization using BC 547 and arduino is a simple task. "Transistor as a switch" principle is used here. We had already seen the Circuit to Turn On an LED During Night and Turn Off the Same During Day Using LDR. In that circuit, a light sensing resistor is used to control the base current.  But in this circuit, an arduino mega board will be used. As we know, NOT gate gives a HIGH output if the input is LOW and gives a LOW output if the input is HIGH. In this circuit, input is the state of digital pin of Arduino and output is the LED. Digital pin of Arduino has two states, HIGH and LOW. HIGH is 5V and LOW is 0V. Similarly if the LED turns off, it will be considered as LOW and if it turns on, it will be considered as HIGH. Circuit is done as shown in the following diagram.

Transistor - BC 547 is the transistor used here. It is an NPN transistor and is suitable for small operations.

5V - Normally supplied from arduino or  5V regulator.

R3 -  If R3 is not connected, when transistor turns on, power supply get shorted through C,B,E and F due to the low resistance of transistor. This will increase current abruptly which will damage the transistor as well as power supply.

R4 -  When transistor turns on, for the collector current to flow through the transistor, resistance of  other path ( through CHJF ) should be high. If R4 is not connected, resistance of both parallel paths ( CEF and CHJF ) will be almost same and current will flow through both parallel paths equally, which may turn on the LED even if the transistor is ON.

Observations

LED will TURN OFF when Digital Pin of Arduino is HIGH.
LED will TURN ON  when Digital Pin of Arduino is LOW.

Explanation of the Circuit

"Transistor as a switch" principle is used in this circuit. When transistor act as switch, a small base current is sufficient to drive a large current from collector to emitter ( through CEF ). Then transistor is said to be in saturation. If the base current is less than a particular amount, transistor will be off and current will not flow from collector to emitter ( through CEF ).

Arduino is connected in the circuit in such a way that, it will control the current to the base of transistor. Current reaching the collector pin of transistor have two options. Either it can flow through the transistor to ground ( through CEF ). Otherwise, it can flow through 1K resistor and LED to ground (  through CHJF ). Current always choose low resistance path. That is, if the transistor get sufficient base current, transistor turn on and current at the collector pin will flow from collector to emitter and then to ground ( through CEF ). If the transistor don't have sufficient base current, transistor get turn off. So current will flow through the 1K resistor and LED to ground ( through CHJF ). This will turn on LED. That is, if the base current is not sufficient, transistor will turn off and LED will turn on.

Arduino controlls the current through the base of transistor. When the digital pin of arduino is at HIGH level, then the base of transistor will get sufficient current and transistor will turn on. So current will flow through transistor ( CEF ) and LED will not get sufficient current. So LED will turn off. Similarly, when the digital pin of arduino is at a LOW level, then the base of transistor will not get sufficient current and transistor will turn off. So current will flow through 1K resistor and LED ( CHJF ) and LED will turn on.

Arduino Program.

int base_current = 2; // Digital pin selected to Control base current is 2

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(base_current, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(base_current, HIGH);   // turn the LED OFF by making INPUT HIGH
delay(1000);               // wait for a second
digitalWrite(base_current, LOW);    // turn the LED ON by making INPUT LOW
delay(1000);               // wait for a second
}

Output

If uploading is successfull, LED will turn ON when Digital pin is LOW and LED will turn OFF when Digital pin is HIGH.