# LED Blink with Transistor

#### Bender Bending Rodriguez

Joined Dec 20, 2015
7
I have an assignment that requires me to have 3 LED's in a series, blinking. The main idea is to use a BJT transistor to accomplish this task. I'm using a BC547C.

Unfortunately the class I'm taking is not in my native language. Luckily the teacher drew the schematic for me and I took a picture, and in order to meet the rules of the forum, I used KiCad to make the schematics and exported it into a PDF (see attachment). It was my first one, I apologize if its quality is lacking. I can also upload the original picture if that helps better.

My problem is that the LED's won't blink, they simply stay on.
We're using the Arduino as the 5V power source. The teacher said that I don't have to use a resistor between the 9V battery and the LED's. I've tried with and without it, different resistances, etc. I've tried to calculate how much resistance I'd need. Nothing seems to work, the LED's just stay on the whole time. The teacher said to only use the resistors, the LED's and the transistors, nothing else. I'm puzzled, what am I missing?

#### Attachments

• 4.5 KB Views: 32

#### nerdegutta

Joined Dec 15, 2009
2,676
Hi, and welcome to AAC.

What is the name of the class you are taking?

Since you are using an Arduino as the 5 volt power source, I'm guessing you should write a program that blinks the LEDs.

The circuit you drew in KiCAD works as expected.

#### Jony130

Joined Feb 17, 2009
5,180
This circuit will never "blink". Try using Arduino and his GPIO and some code as a blinker. Or buy a LED which already "blinks".

#### Bender Bending Rodriguez

Joined Dec 20, 2015
7
@nerdegutta Thanks.

In English ? I think it translates to Electronics ? And the teaching material he was using was a book named "Analog Electronics" in Finnish.

@nerdegutta and @Jony130
No, programming as far as I'm aware. We already did some Flowcode exercises that had a blinking LED.
This was supposed to be a demonstration of how a transistor can act as a switch.

But if you're saying it's impossible it could be that I misinterpreted ? It's just that not once did he mention writing any code nor using any ports other than 5V and GND on the Arduino...

#### GopherT

Joined Nov 23, 2012
8,012
I have an assignment that requires me to have 3 LED's in a series, blinking. The main idea is to use a BJT transistor to accomplish this task. I'm using a BC547C.

Unfortunately the class I'm taking is not in my native language. Luckily the teacher drew the schematic for me and I took a picture, and in order to meet the rules of the forum, I used KiCad to make the schematics and exported it into a PDF (see attachment). It was my first one, I apologize if its quality is lacking. I can also upload the original picture if that helps better.

My problem is that the LED's won't blink, they simply stay on.
We're using the Arduino as the 5V power source. The teacher said that I don't have to use a resistor between the 9V battery and the LED's. I've tried with and without it, different resistances, etc. I've tried to calculate how much resistance I'd need. Nothing seems to work, the LED's just stay on the whole time. The teacher said to only use the resistors, the LED's and the transistors, nothing else. I'm puzzled, what am I missing?

Which pin on the arduino are you using?

Please show that in a schematic.

Also, you can load your photos of circuits - you do not have to draw PDF. Pictures of hand-drawn circuits work fine. Just turn the camera resolution to a reasonable level so the files are not huge.

The Arduino has an LED on the board. It is connected to PIN 13 .

You can practice with this code...
Code:
int ledPin = 13;                 // LED connected to digital pin 13

void setup()
{
pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
digitalWrite(ledPin, HIGH);   // sets the LED on
delay(1000);                  // waits for a second
digitalWrite(ledPin, LOW);    // sets the LED off
delay(1000);                  // waits for a second
}
When you are ready to connect to your external circuit, connect the Base of your NPN transistor to a Digital I/O port on the arduino. Then change the code above from 13 (first line) to the new digital I/O number you connected to.

#### nerdegutta

Joined Dec 15, 2009
2,676
Could your teacher mean that you need to use two transistors to make a flasher? As @GopherT says, upload the picture of the schematic your teacher drew.

#### djsfantasi

Joined Apr 11, 2010
6,691
I, too, think you will need some code. When you connect the transistor base to the digital pin on the Arduino, it is acting as a switch. When your sketch sets the pin high, the transistor will switch and connect the LEDs to ground. Likewise, when you set the pin low, the transistor switches off and the LEDs also turn off.

#### ISB123

Joined May 21, 2014
1,236
If you teacher exactly said LED Blinker it could mean that you should use the example code from Arduino which is called like so.

#### Bender Bending Rodriguez

Joined Dec 20, 2015
7
Okay the picture is attached(sorry about the size. I'm on someone's phone but at least I was able to find it)

I myself have been thinking that we need code, but the thing is that with code this becomes so much simpler to do, no ? I find it hard to believe it took everyone in class eight hours to get it to work, especially with so many examples like that readily available online.

Good point, I don't think he said there was a limit on transistors. So maybe this flasher is what I have to build ?

No, he didn't say LED Blinker (from the Arduino site ?). He's never used the Arduino IDE.

Oh and one thing I forgot to mention I had another class named Digital Electronics if that helps say what kind of class this one is.

#### Attachments

• 384 KB Views: 22

#### djsfantasi

Joined Apr 11, 2010
6,691
The Arduino connection is ambiguous. It it labeled 5v AND 1. Assuming the one is the PIN number, that is used for serial transmission on the Arduino.

Not a problem if the sketch doesn't contain "Serial.begin". But when uploading the sketch, the circuit should be disconnected. Then, the Arduino Blink sketch would be modified so that "ledPin=1". Personally, I'd use another pin.

Or he could have meant the 5v pin, in which case his drawn circuit won't blink.,,

#### BramLabs

Joined Nov 21, 2013
98
Woah, i practice arduino for the first time and use it to make a blinking led ( at the first, i didn't use a transistor as a switch ).

I think you should use PWM from your arduino pin digital for giving 5 volt and 0 volt and 5 volt and 0 volt and so on....so that the transistor BJT will be biased on the saturation region and cut-off region and make your led blinking ( remember to calculate the resistor on your base of transistor and collector of your transistor correctly ).

Oh yeah, and yes, you should learn how to use PWM using your arduino digital pin (it means you should program the arduino).

You can't use only 5 volt from your arduino pin as supply at the base of your transistor and make it blinking without adding any transistor ( maybe you should try to google astable multivibrator transistor ) or using switch (switch + operate the transistor which acts like a switch) to make it blinking.
I think your teacher told you to use an arduino to work with the PWM.

Last edited:

#### Jony130

Joined Feb 17, 2009
5,180
BramLabs
Why PWM ? PWM is for dimming the led, not for the blinking.

#### BramLabs

Joined Nov 21, 2013
98
Sir Jony130

Oh yeah, i'm sorry, i mean dimming. ahahahaha....

Just use a program as Sir GopherT has mentioned above, and you can set the delay to make a faster blinking or slower blinking.

Code:
int ledPin = 13;                 // LED connected to digital pin 13

void setup()
{
pinMode(ledPin, OUTPUT);      // sets the digital pin as output
}

void loop()
{
digitalWrite(ledPin, HIGH);   // sets the LED on
delay(1000);                  // waits for a second
digitalWrite(ledPin, LOW);    // sets the LED off
delay(1000);                  // waits for a second
}
And try it with different port digital ( pin digital 13 ady has a led attach on it )

Thank you for your correction sir

Last edited:

#### shteii01

Joined Feb 19, 2010
4,644
Woah, i practice arduino for the first time and use it to make a blinking led ( at the first, i didn't use a transistor as a switch ).

I think you should use PWM from your arduino pin digital for giving 5 volt and 0 volt and 5 volt and 0 volt and so on....so that the transistor BJT will be biased on the saturation region and cut-off region and make your led blinking ( remember to calculate the resistor on your base of transistor and collector of your transistor correctly ).

Oh yeah, and yes, you should learn how to use PWM using your arduino digital pin (it means you should program the arduino).

You can't use only 5 volt from your arduino pin as supply at the base of your transistor and make it blinking without adding any transistor ( maybe you should try to google astable multivibrator transistor ) or using switch (switch + operate the transistor which acts like a switch) to make it blinking.
I think your teacher told you to use an arduino to work with the PWM.
OP said that he needs to blink 3 LED. The 3 LED are connected in series. Let us ASSUME that each led has a forward voltage (Vf) of 2 volts. 3 LED in series will have Vf of? 2+2+2=6 volts. Can Arduino Uno (5 volt system) supply 6 volts from one of its pins? No. Can Arduino Due (3.3 volt system) supply 6 volts? No. Like OP said, they are not using Arduino to blink led. Arduino provides input to the switch circuit. The transistor is the switch connected to an external voltage source that provides the necessary voltage to turn led on.

OP. The interesting thing about vagueness of your assignment is that you could build an oscillator circuit that uses transistors. I think it is usually 2-4 transistors. Then use the output of this oscillator as an input to your transistor switch circuit. In this way you have purely analog led flashing circuit. You use no electronics, you don't use Arduino board, you don't write any code.

OP. Like others said. The only way to make led flasher using Arduino board is to write code that would send ON/OFF voltage to the transistor switch. For that on Arduino board you can use regular General Purpose Input/Output pin (GPIO), set it up as output, then turn it on, turn it off, the whole thing would be like 8-15 lines of code. Or you can use PWM pin/functionality on the Arduino board. Or, like someone said, you can use Tx pin of the serial communication functionality of Arduino board, but that seems a little more complicated than it needs to be.

#### BramLabs

Joined Nov 21, 2013
98
OP said that he needs to blink 3 LED. The 3 LED are connected in series. Let us ASSUME that each led has a forward voltage (Vf) of 2 volts. 3 LED in series will have Vf of? 2+2+2=6 volts. Can Arduino Uno (5 volt system) supply 6 volts from one of its pins? No. Can Arduino Due (3.3 volt system) supply 6 volts? No. Like OP said, they are not using Arduino to blink led. Arduino provides input to the switch circuit. The transistor is the switch connected to an external voltage source that provides the necessary voltage to turn led on.

OP. The interesting thing about vagueness of your assignment is that you could build an oscillator circuit that uses transistors. I think it is usually 2-4 transistors. Then use the output of this oscillator as an input to your transistor switch circuit. In this way you have purely analog led flashing circuit. You use no electronics, you don't use Arduino board, you don't write any code.

OP. Like others said. The only way to make led flasher using Arduino board is to write code that would send ON/OFF voltage to the transistor switch. For that on Arduino board you can use regular General Purpose Input/Output pin (GPIO), set it up as output, then turn it on, turn it off, the whole thing would be like 8-15 lines of code. Or you can use PWM pin/functionality on the Arduino board. Or, like someone said, you can use Tx pin of the serial communication functionality of Arduino board, but that seems a little more complicated than it needs to be.

Sir shteii01
I think the OP said that he uses battery 9 V as the supply of the LED ( 3 led, assume 2 volt, so it's just need 6 V. 9 Volt supply - 6 Volt for led = 3 Volt remain ) and i agree completely with you. I didn't say to replace the battery 9 V with 5V supply arduino .

OP
I don't completely understand what's the question of OP. He attached a picture using 9 Volt battery and 3 LED at the collector of transistor and 5 V supply using arduino at the base of transistor. But at the end of his question, he said that ( The teacher said to only use the resistors, the LED's and the transistors, nothing else. I'm puzzled, what am I missing? ), then why are OP using arduino as the input to the switch circuit ?
What kind of subject did you take OP ?
If you took a microcontroller subject, i think, your teacher asked you to use arduino as Sir GopherT told you to try.
If you took another subject like Electronics, i think, your teacher just told you to use arduino for supplying the BASE of your transistor with it and use another circuit, OR use another circuit like sir shteii01 has told you, use an oscillator at the BASE of your transistor instead of arduino, so that you can make your transistor switch on and off based on your oscillator circuit.

#### shteii01

Joined Feb 19, 2010
4,644
Sir shteii01
I think the OP said that he uses battery 9 V as the supply of the LED ( 3 led, assume 2 volt, so it's just need 6 V. 9 Volt supply - 6 Volt for led = 3 Volt remain ) and i agree completely with you. I didn't say to replace the battery 9 V with 5V supply arduino .

OP
I don't completely understand what's the question of OP. He attached a picture using 9 Volt battery and 3 LED at the collector of transistor and 5 V supply using arduino at the base of transistor. But at the end of his question, he said that ( The teacher said to only use the resistors, the LED's and the transistors, nothing else. I'm puzzled, what am I missing? ), then why are OP using arduino as the input to the switch circuit ?
What kind of subject did you take OP ?
If you took a microcontroller subject, i think, your teacher asked you to use arduino as Sir GopherT told you to try.
If you took another subject like Electronics, i think, your teacher just told you to use arduino for supplying the BASE of your transistor with it and use another circuit, OR use another circuit like sir shteii01 has told you, use an oscillator at the BASE of your transistor instead of arduino, so that you can make your transistor switch on and off based on your oscillator circuit.
Colpitts Oscillator: http://www.electronics-tutorials.ws/oscillator/colpitts.html
Would be my guess/suggestion.

#### Bender Bending Rodriguez

Joined Dec 20, 2015
7
@djsfantasi might be onto something. I'm wondering if that 1 was there previously or if he put that there for this. I think I'll go that route since everyone says it's impossible otherwise and hope it's what was meant.

@BramLabs
It's an Electronics course. And our study material was an Analog Electronics books. Which all had led me to believe that I shouldn't code but I'll just code and see what he says.

@Everyone
I'd originally thought that the Arduino was just used as a power source but as @djsfantasi said there is a 1 in the image and something got lost in translation.

It seems like I have confused a great many people sorry about that. @shteii01 that oscillator circuit sounds interesting maybe something to work on during the holidays.

A big thank you to everyone for their help! I'll be back tomorrow to let everyone know if it was just a communications issue.

As kind of off-topic, I do wonder...
Isn't that literally the same code for the Blink example on the Arduino site ? I guess the big wow factor is that I'm able to automate the blinking of three lights seeing as the Arduino would only be able to handle two and very dimly. I would think adding a capacitor would've been a much more amazing project...But alas we have none for this exercise.

#### shteii01

Joined Feb 19, 2010
4,644
@djsfantasi might be onto something. I'm wondering if that 1 was there previously or if he put that there for this. I think I'll go that route since everyone says it's impossible otherwise and hope it's what was meant.

@BramLabs
It's an Electronics course. And our study material was an Analog Electronics books. Which all had led me to believe that I shouldn't code but I'll just code and see what he says.

@Everyone
I'd originally thought that the Arduino was just used as a power source but as @djsfantasi said there is a 1 in the image and something got lost in translation.

It seems like I have confused a great many people sorry about that. @shteii01 that oscillator circuit sounds interesting maybe something to work on during the holidays.

A big thank you to everyone for their help! I'll be back tomorrow to let everyone know if it was just a communications issue.

As kind of off-topic, I do wonder...
Isn't that literally the same code for the Blink example on the Arduino site ? I guess the big wow factor is that I'm able to automate the blinking of three lights seeing as the Arduino would only be able to handle two and very dimly. I would think adding a capacitor would've been a much more amazing project...But alas we have none for this exercise.
The code might be from Arduino site. The code does not care how many led the user, you, need to flash. So it is your job to figure out how to modify the led circuit to flash N number of LEDs. In your specific case the instructor told you to use transistor in the role of a switch.

Like I wrote earlier, based on your somewhat vague earlier description, you have two choices:
1) Use Arduino board to turn the transistor switch on and off, and as a result turn on and off the 3 series LEDs. This is "digital" approach.
2) Use oscillator circuit to turn transistor switch on and off. This is analog approach.
So double check with your instructor what they want you to demonstrate.

The Colpitts Oscillator that I linked uses capacitors, inductors and resistors. The reason I linked that one is because it uses transistor so you could build "purely" transistor circuit.
However, finding right inductors can be difficult. Here is simpler RC oscillator, with transistor or with op amp: http://www.electronics-tutorials.ws/oscillator/rc_oscillator.html

#### Bender Bending Rodriguez

Joined Dec 20, 2015
7
You guys were right! Thanks for the help! If you hadn't told me it was impossible I'd probably still be trying to figure out how to get it to work!

Sorry for bumping the thread up with this post, I just wanted to let you know what the final result was. I was wondering what is the proper etiquette on letting a thread know it has been solved ?
I would've just edited a previous post but I don't have enough posts to do that just yet. I suppose I should ask if someone can lock this thread so that no one thinks I'm still trying to figure this out ?
You can PM me the answer to this so that this thread doesn't go off-topic.

@shteii01 I suppose I see what you mean. For a first programming/transistor task it is a challenge.
Thanks again for all the references.