Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
For you

Electrical Engineering
Results will update as you type.
  • Aesthetic elements in Eagle
  • Actuators and Outputs
  • Aktuatoren (DE)
  • Analog Input
  • Analog Sensors
  • Arduino Grundlagen
  • Arduino Programmieren
  • Arduino und Processing
  • Shift Registers
  • Carvey
  • Capacitors
  • Bread Boards
  • Digitaler Input
  • Digitaler Output
  • Eagle
  • Energy Harvesting
  • H-Bridge
  • I2C (en)
  • Interrupt Service Routine
  • Mosfet Transistor
  • LED
  • PCBs Herstellen
  • Pololu Servo Controller
  • Relays as Switches
  • Pulse Width Modulation
  • RFiD
  • Schrittmotorentreiber
  • SD Karten
  • Signal Filtering
  • Transistors as Switches
    • Transistor als Schalter (DE)
  • Widerstand
  • PCB Manufacturing
  • PlatformIO
  • Lynx Smart Motion Servo
  • Electronics Basics (EN)
  • Arduino Basics (en)
  • Arduino Programming (EN)
  • Digital Outputs (en)
  • Digital Input (en)
  • Serial Communication (en)
  • Pulse Width Modulation (en)
  • Resistors (en)
  • Arduino and P5.js
  • Arduino and ml5.js
  • Project box 2021
  • Servo Motors
  • H-Bridge (DE)
  • Networking
  • Bit Shifting
  • C++ (Arduino) Variables
  • Stepper Motor Drivers
  • Interrupt Service Routine (en)
  • Common Arduino Problems
  • Finite State Machine
  • Voltage Regulators
  • Arduino USB HID (Human Interface Devices)

    Two hearts overlapped with each other
    Welcome back
    Catch up on the top discussions and highlights from your team.
    /
    Transistors as Switches
    Updated Oct 06, 2021

    Transistors as Switches

    Oct 06, 2021

    Analytics

    Loading data...

    German Version

    When we talk about "transistors", we usually mean a bipolar transistor. Transistors consist of semiconductors, which means they can transition from conducting to non-conducting. These properties can be used as a kind of electrically activated "switch". This makes it possible to switch larger loads with small ones. This can be really useful, for example, if a larger relay, motor or lightbulb needs to be switched with an Arduino board.

    You can imagine the transistor like a switch. When the switch is pressed, the current flows. If the switch is released, the current no longer flows. The transistor has three connections: Base, Emitter and Collector. The voltage at the base-emitter switches the collector-emitter path. The circuit of a transistor depends on its type. There are two main types of transistors: NPN and PNP transistors. The current direction (collector-emitter) must be observed, otherwise, the transistor could be damaged. We will use NPN transistor most of the time.

    Here is a drawing from the Datasheet of the TIP 122, which shows where base, emitter and collector pins can be found

    The following diagram visualizes the current flow (I/red) and the voltage flow (U/blue) which are applied to the transistor. Important: A base resistor (RB) and a load are always required for correct operation.


    UCE = Collektor-Emitter-Voltage
    UE = Driving Voltage
    UBE = Base-Emitter-Voltaege (Threshold value)
    IC = Collector Current 
    IB = Base current
    RB = Base resistor 

    The Transistor as a Switch

    A common use of a transistor is in the switching of higher loads - since most microcontrollers are limited in their output power on digital pins. For example, the Arduino can switch a load of 5V at 20mA per output. This is enough for LED's and maybe a small vibration motor. However, if a fan, a high power LED, a solenoid, a motor, etc. is connected you definitely need a transistor circuit. In this case, the transistor works similar to a relay: it switches higher loads with smaller loads. A distinction must also be made between switching non-inductive loads (e.g. LED) and inductive loads (e.g. fan, relay, motor). An inductive load will probably need a Fly Back Diode. 

    Switching a non-inductive Load

    For switching a non-inductive load, the transistor circuit is very simple to set up. You only need an NPN transistor (TIP 122) and a series resistor in the path IB (1 kOhm). The circuit diagram looks as follows:

    R1 = 1 kOhm (approximate value)
    Transistor = TIP 122

    Example

    In this example, we want to light up the RGB LED strip and control its brightness. According to the labelling and datasheet, the strip needs 12V supply voltage - corresponding resistors are already present and soldered on the strip. To realize this circuit we need a 12V power supply, one transistor (TIP 122 NPN) per channel, one resistor (1kOhm) per channel and the Arduino.

    The following setup is needed to control a single color (here red)...



    We program the Arduino with the following example code, which fades the red channel back and forth.

    Example with PWM and Transistor
    #define RED_LED 10 // PWM PIN void setup() { pinMode(RED_LED, OUTPUT); } void loop() { for (int i = 0; i < 255; i++) { analogWrite(RED_LED, i); delay(10); } for (int i = 255; i > 0; i--) { analogWrite(RED_LED, i); delay(10); } }

    Exercise

    1. Extend the previously developed circuit so that all three channels of the RGB LED strip can be controlled differently.

    2. Program a colour change that fades between red, green and blue (logic: off>red>green>blue>off).



    Solution Exercise 2
    #define RED_LED 11 // PWM Pin #define GRN_LED 10 // PWM PIN #define BLU_LED 9 // PWM fPIN void setup() { pinMode(RED_LED, OUTPUT); pinMode(GRN_LED, OUTPUT); pinMode(BLU_LED, OUTPUT); } void loop() { for (int i = 0; i < 255; i++) { analogWrite(RED_LED, i); delay(10); } for (int i = 255; i > 0; i--) { analogWrite(RED_LED, i); // D analogWrite(GRN_LED, (-1) * (255 - i)); delay(10); } for (int i = 255; i > 0; i--) { analogWrite(GRN_LED, i); analogWrite(BLU_LED, (-1) * (255 - i)); delay(10); } for (int i = 255; i > 0; i--) { analogWrite(BLU_LED, i); delay(10); } }

    Further Information

    Make Presents: The Transistor
    Bipolarer Transistor 
    Der Transistor als Schalter 

    {"serverDuration": 12, "requestCorrelationId": "bed5736b5ceb4e84a43007056a2daa8e"}