Hello guys In this tutorial we will see how to control 12V LED and motor with 5V Arduino by using Transistor TIP122. And we are using transistor as a switch and also controlling led and motor with plus width modulation. We will also see how to calculate base current resistor. So let’s get started.

For this you will need

1. Arduino,
2. Transistor (TIP 122),
3. Diode (1N4007) (If you are controlling motor),
4. 12V battery,
5. 2.2K ohms Resistor,
6. Jumper Wire,
8. 12V LED, (If you are controlling LED)
9. 12V Motor (If you are controlling Motor)

First we need to calculate base resistor for transistor. Using this method you can find any transistor base resistance. Download data sheet of transistor TIP 122.

Now goto page number 3 and in second figure we can see equation

Ic = 250 X Ib,

So we need to check how much load current is require to run a motor. My motor require 0.44Amp current. It may be printed on motor or it is written in motor specification. So my Ic value will be 0.44Amp. Now calculate Ib which is equal to 1.76mA.

Ib= 1.76mA

Look at figure 2 again now we know collector current. Check 0.44 value in figure 2 and match with Vbe saturation. Its value is around 1.375 V.

Vbe= 1.375 V

It means that Arduino has voltage drop of (5-1.375) which is equal to 3.625V. Now according to ohms law R = V/Ib.

3.625/1.76×10-3 = 2059.65 ohms

So we get 2059 ohms as a base current resistor value.

but I am using 2.2K ohms resistor. You can calculate base resistor according to your load current.

To control 12V LED we need to connect our circuit like this. After doing connection. Open Arduino IDE software, goto file > Examples > Basics > blink. Upload led blink sketch.

```// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
delay(1000);                       // wait for a second
digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
delay(1000);                       // wait for a second
}```

Now we can see we are using transistor as a switch it will turn on and off 12V led for 1 second. Now again goto Arduino IDE software file > Examples > Basics > fade, upload fade sketch from examples. Change pin number to 9.

```int led = 9; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
// declare pin 9 to be an output:
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led, brightness);

// change the brightness for next time through the loop:

// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}```

Now we can see it is fade on and off. We are controlling this with plus width modulation. Now we will control motor. Just add diode across the motor. Now upload the blink sketch. I have given 1 second delay for ON and 3 second delay for OFF. So that we can see clearly motor is stop spinning.

Now we will control motor with plus width modulation. Upload the sketch of fade from examples. Now we can see it is varying its speed in every 300 millisecond. Till then keep learning keep making.

Categories: Arduino

### 1 Comment

#### Make Your Own Sound Activated 12V RGB Party Light - Robotica DIY · March 5, 2020 at 10:36 am

[…] to use it or want to know how to calculate resistance for TIP122 you can see my previous tutorial control 12V LED or Fan from 5V with Arduino. I have already calculated base current resistance, so I am using 2.2K ohms […]