Home LearningBasics Transistor example

Transistor example

by shedboy71

The circuit shown here uses a NPN transistor connected to a an Arduino output pin to switch an LED pin. In real life you would perhaps switch a relay, lamp , fan or a buzzer. A darlington transistor could be used to drive a motor for example.

In this example we use the 5v from the Arduino but in real life again the device that the transistor is driving may have its own seperate power supply.

The example we will show is quite basic we simply send a low or a high to the base of the transistor and in turn the LED will either switch on or off.

 

arduino and transistor schematic

arduino and transistor schematic

More commonly you will see something like the following, this time driving a 12v motor using a TIP122 darlington transistor

arduino to motor

arduino to motor

Code

 
[c]
const int transistorPin = 3;

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

void loop()
{
digitalWrite (transistorPin, HIGH);
delay (1000);
digitalWrite (transistorPin, LOW);
delay (1000);
}
[/c]

Share

You may also like