Scale-N

Scale-N
Arduino
Componenten
Rollend Materieel
Naslag
Onderdelen
Wissels
Basis Electronica
Symbols Electronica
Programming Arduino
DCC++
DR5000
Products
Link













































18. Digital logic switch NPN - PNP

Difference Between NPN and PNP Transistor
NPN:The transistor switches ON with the increase in current in the base terminal
PNP:The transistors switch ON when there is no current flow at the base terminal

NPN transistor
Example circuit using an NPN transistor.


Breadboard
BC547 transitor
Arduino Nano
Green LED
resistors: 330 ohm, 1000ohm
Capacitor 20nf
Breadboard jumpers

Digital out pin 2 is used to flip the switch by sending the base of the transistor alternately high and low.
Code:
const int transistor = 2;

void setup() {
  pinMode(transistor, OUTPUT);
}

void loop() {
  digitalWrite(transistor, HIGH);
  delay(1000);
  digitalWrite(transistor, LOW);
  delay(1000);
}


Aside from the LED, an analog input pin is used to read a voltage in the load chain.

Connection:
  • BC547
    • Base (B): 330 ohm, Arduino D2
    • Collector (C): Green LED, Resistor 1000 ohm, 5V
    • Emitter (E): Ground
  • Capacitor: BC547 Collector (C) => BC547 Emitter (E)
  • Voltage read: BC547 Collector (C) => Arduino A0
Download ino


PNP transistor
Example circuit using an PNP transistor.


Breadboard
BC557 transitor
Arduino Nano
Green LED
resistors: 330 ohm, 1000ohm
Capacitor 20nf
Breadboard jumpers

Digital out pin 2 is used to flip the switch by sending the base of the transistor alternately high and low.
Code (Same as above):
const int transistor = 2;

void setup() {
  pinMode(transistor, OUTPUT);
}

void loop() {
  digitalWrite(transistor, HIGH);
  delay(1000);
  digitalWrite(transistor, LOW);
  delay(1000);
}


Aside from the LED, an analog input pin is used to read a voltage in the load chain.

Connection:
  • BC557
    • Base (B): 330 ohm, Arduino D2
    • Collector (C): Green LED, Resistor 1000 ohm, Ground/li>
    • Emitter (E): 5V
  • Capacitor: BC557 Collector (C) => BC547 Emitter (E)
  • Voltage read: BC557 Collector (C) => Arduino A0
Download ino (Same as above)