## Step 4: .:8 LED Fun:. (Multiple LEDs) - CIRC02

What We're Doing:
We have caused one LED to blink, now its time to up the stakes. Lets connect eight. We'll also have an opportunity to stretch the Arduino a bit by creating various lighting sequences. This circuit is also a nice setup to experiment with writing your own programs and getting a feel for how the Arduino works.

Along with controlling the LEDs we start looking into a few simple programming methods to keep your programs small.

for() loops - used when you want to run a piece of code several times.
arrays[] - used to make managing variables easier (its a group of variables)

The Parts:
• 5mm Green LED (x8)
• 560 ohm Resistor (green-blue-brown) (x8)

The Circuit and Plugging Everything In:
A Small Video of Everything Being Plugged in

The Code:

`/*     --------------------------------------------------------- *     |  Arduino Experimentation Kit Example Code             | *     |  CIRC-02 .: 8 LED Fun :. (Multiple LEDs)   | *     --------------------------------------------------------- *   *  A few Simple LED animations * * For more information on this circuit http://tinyurl.com/d2hrud * *///LED Pin Variablesint ledPins[] = {2,3,4,5,6,7,8,9}; //An array to hold the pin each LED is connected to                                   //i.e. LED #0 is connected to pin 2, LED #1, 3 and so on                                   //to address an array use ledPins[0] this would equal 2                                   //and ledPins[7] would equal 9/* * setup() - this function runs once when you turn your Arduino on * We the three control pins to outputs */void setup(){    //Set each pin connected to an LED to output mode (pulling high (on) or low (off)  for(int i = 0; i < 8; i++){         //this is a loop and will repeat eight times      pinMode(ledPins[i],OUTPUT); //we use this to set each LED pin to output  }                                   //the code this replaces is below   /* (commented code will not run)   * these are the lines replaced by the for loop above they do exactly the   * same thing the one above just uses less typing  pinMode(ledPins[0],OUTPUT);  pinMode(ledPins[1],OUTPUT);  pinMode(ledPins[2],OUTPUT);  pinMode(ledPins[3],OUTPUT);  pinMode(ledPins[4],OUTPUT);  pinMode(ledPins[5],OUTPUT);  pinMode(ledPins[6],OUTPUT);  pinMode(ledPins[7],OUTPUT);  (end of commented code)*/}/* * loop() - this function will start after setup finishes and then repeat * we call a function called oneAfterAnother(). if you would like a different behaviour * uncomment (delete the two slashes) one of the other lines */void loop()                     // run over and over again{  oneAfterAnotherNoLoop();   //this will turn on each LED one by one then turn each off  //oneAfterAnotherLoop();   //does the same as oneAfterAnotherNoLoop but with much less typing  //oneOnAtATime();          //this will turn one LED on then turn the next one on turning the                              //former off (one LED will look like it is scrolling along the line  //inAndOut();              //lights the two middle LEDs then moves them out then back in again}/* * oneAfterAnotherNoLoop() - Will light one LED then delay for delayTime then light * the next LED until all LEDs are on it will then turn them off one after another * * this does it without using a loop which makes for a lot of typing.  * oneOnAtATimeLoop() does exactly the same thing with less typing */void oneAfterAnotherNoLoop(){  int delayTime = 100; //the time (in milliseconds) to pause between LEDs                       //make smaller for quicker switching and larger for slower  digitalWrite(ledPins[0], HIGH);  //Turns on LED #0 (connected to pin 2)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[1], HIGH);  //Turns on LED #1 (connected to pin 3)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[2], HIGH);  //Turns on LED #2 (connected to pin 4)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[3], HIGH);  //Turns on LED #3 (connected to pin 5)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[4], HIGH);  //Turns on LED #4 (connected to pin 6)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[5], HIGH);  //Turns on LED #5 (connected to pin 7)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[6], HIGH);  //Turns on LED #6 (connected to pin 8)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[7], HIGH);  //Turns on LED #7 (connected to pin 9)  delay(delayTime);                //waits delayTime milliseconds  //Turns Each LED Off  digitalWrite(ledPins[7], LOW);  //Turns on LED #0 (connected to pin 2)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[6], LOW);  //Turns on LED #1 (connected to pin 3)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[5], LOW);  //Turns on LED #2 (connected to pin 4)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[4], LOW);  //Turns on LED #3 (connected to pin 5)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[3], LOW);  //Turns on LED #4 (connected to pin 6)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[2], LOW);  //Turns on LED #5 (connected to pin 7)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[1], LOW);  //Turns on LED #6 (connected to pin 8)  delay(delayTime);                //waits delayTime milliseconds  digitalWrite(ledPins[0], LOW);  //Turns on LED #7 (connected to pin 9)  delay(delayTime);                //waits delayTime milliseconds  }/* * oneAfterAnotherLoop() - Will light one LED then delay for delayTime then light * the next LED until all LEDs are on it will then turn them off one after another * * this does it using a loop which makes for a lot less typing.  * than oneOnAtATimeNoLoop() does exactly the same thing with less typing */void oneAfterAnotherLoop(){  int delayTime = 100; //the time (in milliseconds) to pause between LEDs                       //make smaller for quicker switching and larger for slower//Turn Each LED on one after another  for(int i = 0; i <= 7; i++){    digitalWrite(ledPins[i], HIGH);  //Turns on LED #i each time this runs i    delay(delayTime);                //gets one added to it so this will repeat   }                                  //8 times the first time i will = 0 the final                                     //time i will equal 7;//Turn Each LED off one after another  for(int i = 7; i >= 0; i--){  //same as above but rather than starting at 0 and counting up                                //we start at seven and count down    digitalWrite(ledPins[i], LOW);  //Turns off LED #i each time this runs i    delay(delayTime);                //gets one subtracted from it so this will repeat   }                                  //8 times the first time i will = 7 the final                                     //time i will equal 0;                                                                          }/* * oneOnAtATime() - Will light one LED then the next turning off all the others */void oneOnAtATime(){  int delayTime = 100; //the time (in milliseconds) to pause between LEDs                       //make smaller for quicker switching and larger for slower    for(int i = 0; i <= 7; i++){    int offLED = i - 1;  //Calculate which LED was turned on last time through    if(i == 0) {         //for i = 1 to 7 this is i minus 1 (i.e. if i = 2 we will      offLED = 7;        //turn on LED 2 and off LED 1)    }                    //however if i = 0 we don&apos;t want to turn of led -1 (doesn&apos;t exist)                         //instead we turn off LED 7, (looping around)    digitalWrite(ledPins[i], HIGH);     //turn on LED #i    digitalWrite(ledPins[offLED], LOW); //turn off the LED we turned on last time    delay(delayTime);  }}/* * inAndOut() - This will turn on the two middle LEDs then the next two out * making an in and out look */void inAndOut(){  int delayTime = 100; //the time (in milliseconds) to pause between LEDs                       //make smaller for quicker switching and larger for slower    //runs the LEDs out from the middle  for(int i = 0; i <= 3; i++){    int offLED = i - 1;  //Calculate which LED was turned on last time through    if(i == 0) {         //for i = 1 to 7 this is i minus 1 (i.e. if i = 2 we will      offLED = 3;        //turn on LED 2 and off LED 1)    }                    //however if i = 0 we don&apos;t want to turn of led -1 (doesn&apos;t exist)                         //instead we turn off LED 7, (looping around)    int onLED1 = 3 - i;       //this is the first LED to go on ie. LED #3 when i = 0 and LED #0 when i = 3     int onLED2 = 4 + i;       //this is the first LED to go on ie. LED #4 when i = 0 and LED #7 when i = 3     int offLED1 = 3 - offLED; //turns off the LED we turned on last time    int offLED2 = 4 + offLED; //turns off the LED we turned on last time        digitalWrite(ledPins[onLED1], HIGH);    digitalWrite(ledPins[onLED2], HIGH);        digitalWrite(ledPins[offLED1], LOW);        digitalWrite(ledPins[offLED2], LOW);            delay(delayTime);  }  //runs the LEDs into the middle  for(int i = 3; i >= 0; i--){    int offLED = i + 1;  //Calculate which LED was turned on last time through    if(i == 3) {         //for i = 1 to 7 this is i minus 1 (i.e. if i = 2 we will      offLED = 0;        //turn on LED 2 and off LED 1)    }                    //however if i = 0 we don&apos;t want to turn of led -1 (doesn&apos;t exist)                         //instead we turn off LED 7, (looping around)    int onLED1 = 3 - i;       //this is the first LED to go on ie. LED #3 when i = 0 and LED #0 when i = 3     int onLED2 = 4 + i;       //this is the first LED to go on ie. LED #4 when i = 0 and LED #7 when i = 3     int offLED1 = 3 - offLED; //turns off the LED we turned on last time    int offLED2 = 4 + offLED; //turns off the LED we turned on last time        digitalWrite(ledPins[onLED1], HIGH);    digitalWrite(ledPins[onLED2], HIGH);        digitalWrite(ledPins[offLED1], LOW);        digitalWrite(ledPins[offLED2], LOW);            delay(delayTime);  }}  `

Not Working?
• Some LEDs Fail to Light - It is easy to insert an LED backwards. Check the LEDs that aren't working and ensure they the right way around.
• Operating out of sequence - With eight wires it's easy to cross a couple. Double check that the first LED is plugged into pin 2 and each pin there after.
• Starting Afresh - Its easy to accidentally misplace a wire without noticing. Pulling everything out and starting with a fresh slate is often easier than trying to track down the problem.

Making it Better:
Switching to Loops:
in the loop() function there are 4 lines. The last three all start with a '//' this means the line is treated as a comment (not run). To switch the program to use loops change the void loop() code to:
`  //oneAfterAnotherNoLoop();     oneAfterAnotherLoop();     //oneOnAtATime();            //inAndOut();`
Upload the program, and notice that nothing has changed. You can take a look at the two functions, each does the same thing, but use different approaches (hint the second one uses a for loop)

Extra Animations:
Tired of this animation? Then try the other two sample animations. Uncomment their lines and upload the program to your board and enjoy the new light animations. (delete the slashes in front of row 3 and then 4)

Jump into the included code and start changing things. The main point is to turn an LED on use digitalWrite(pinNumber, HIGH); then to turn it off use digitalWrite(pinNumber, LOW); . Type away, regardless of what you change you won't break anything.

<p>Very good article, thank you for valuable information!</p>
<p>Hi there! I bought your ARDX kit and it's been fun following the projects. The only problem I've been having is that the breadboard is very stiff and some of the components won't insert. Do you have any tips for warming up the breadboard so wires will go in smoothly?</p>
<p>I'm having a problem with circuit 11. I can't change the delay (it keeps flicking back and forth between green and red at one second intervals no matter how much delay I put in the code), and I can't change the pin to any other pin but 2. I'm trying to integrate this circuit with another one so I need be able to make changes!</p>
<p>can i use this relay to control and lamp?</p>
Hi, when I plug the arduino in the power light comes on and the led flashes but the new device box does not pop up, I'm not able to select a port it. How do I install the drivers, I can't seem to find the arduino on my computer. I'm running Windows 7. Your help is much appreciated. Thank you
<p>If you bought an official Arduino you can find the driver at <a href="http://www.arduino.cc/" rel="nofollow">http://www.arduino.cc/</a><br><br>If you bought a chinese one from eBay, read the description again. Most of them that I've seen use a different USB controller and also have a link to the required driver in their description.</p>
<p>Thanx !! All project suggestions are much appreciated !!!</p>
<p>Can some explain to me the in and out configuration when I have 10 leds. This is to test my learning capability. </p>
N00b here. I've built the Circ01 and Circ02 projects and now as i hit Circ03 the question still remains: <br> <br>Exactly what are the 2-pin Headers for? <br> <br>thanks <br>
<p>I guess the 2 pin headers hold the template in place. Nothing more than that. If you are not using the template then you don't need the headers.</p>
<p>I'm just wondering about the role of the resistors in this example. Couldn't these be replaced with Jumper wires without having any detrimental effect on the solution?</p>
<p>I don't understand why for(int i = 0; i &lt; 8 ; i++) even works. if i is set to 0, then i is less than 8, right? for(int i = 0; i =7 ; i++) does nothing, and for(int i = 0; i == 7 ; i++) works correctly except the LEDs are lit at ~10%. What's happening here?</p>
<p>The first one (for(int i=0;i&lt;8;i++)) works because it tests if i is less then 8 and if it is, it runs the code. for(int i=0,i=7,i++) does nothing because when it starts i equals 0 and fails the test &quot;does i equal 7?&quot; and breaks out of the for loop. </p>
<p>Hey - fun project! I had no problems getting it to work. then I hacked it a bit to count to 1024 (2 extra LEDs). I'm interested in using this to count passers-by. I have a second IR beam-breaking detector that provides a ground when the beam is interrupted. I would like to feed this ground signal into D13 so that when grounded, the binary count would increment by one. Can anyone recommend how to tweak the code to look for a ground on D13 thereby incrementing the count by one? </p><p>Thanks!! M&oslash;</p>
I don't understand the purpose of the wire running to 5v. It connects the positive rail on the breadboard to 5v but I don't see anything on the breadboard connected to the positive rail. Here's my new-to-Arduino question: obviously all of the LEDs ground through the resistors=&gt;negative rail=&gt; GRND on Arduino. Do they get all the power they need (+) from the pins 2~9 being controlled by the code? Right now I'm running it completely without the wire to 5V and it runs but LEDs are dim.
<p>You are correct, you technically do not need the 5v wire from the ardunio to the positive side of the breadboard, the positive voltage comes from the pins (2-9) all the code actually does is turns the voltage on or off through the pins, thus the circuit completes through the negative rail on the breadboard, and lights the LED.</p>
<p>THANK YOU TO INSTRUCTIONALS AND <a href="https://www.instructables.com/member/oomlout/" rel="nofollow">oomlout</a>!!!!!!!!!!!!!!!!!!!!!!!!!!!!</p><p>To Instructionals for having this site and to <a href="https://www.instructables.com/member/oomlout/" rel="nofollow">oomlout</a> for posting the instruction as to how this circuit works. I got to this circuit, hooked it up, nothing---changed out all the parts from Arduino kit, still nothing, took out all the parts, rewired it, still nothing, found a dead laptop, took out the cooling fan, reading voltage(5v) and working amps, (.35a), put in a LED where the motor should be, the LED blinked on/off per 1 sec, the circuit works with a LED but not motor,,,soldered pins TO the laptop fan, installed fan.. nothing,, then i checked the amps across the base to collector, it read like .00004ma, i think, it was pretty low amp reading, it works with a LED but not motor,mmmmm, went to an electronics store about asked a transistor with a higher gain, nice lady there found a TO-18 case that had a gain of 200, came back plugged that part in,,noting CBE and the tab.</p><p>moment of Poooof, making sure I had the CBE correct, plugged in the laptop fan, plugged in power, ANNNNNNNNNNNNNNNNNNNNND,,, the freaking thing works, cycles on 1 sec, off 1 sec. </p><p>wowoow on to the next project</p><p>so to all of you instructable people out there,</p><p>********* DON'T GIVE UP!! KEEP TRYING, YOU'LL GET IT.. ********</p>
<p>can i copy and paste the code or no </p>
I am new to the electronics things,so please forgive me,if my question seems to be a foolish one.My doubt is.. <br>Why the transistor is connected after the motor and why not before??? If i am right current flows from +ve to -ve and in that case the transistor is placed after the current passes through the motor.Why so??In that case how is the transistor helpful in this circuit for amplifying current?? Can you please help me out of this confusion. <br>Thanks
Friend <br>I am about to begin experimenting with Arduino and this kit of experimentation which we teach and explain how to use seems to me to be excellent. I bought a platform type arduino with all the accessories of the Upgrade Industries brand called XBoard which is ideal for experimenting, ideal to attach it to the kit samples. Be the Xboard is 100% compatible with the kit that you recommend? Thank you
I am stuck on the 'controlling a motor' part. I am not sure how I by-pass the 560 Ohm resister. I have removed the red LED but how do I connect the motor?
I am just getting started with Arduino and am having a problem with Circ03. The motor will run, but does not go on and off, and the variable speed just runs at the same speed. <br>
Why do we connect a wire directly to 5v when pin 13 is already getting 5v. I inadvertently pulled off the 5v wire and the circuit still worked. <br> <br>I assume this is just some kind of best practice that is useful 90% of the time but just not in this case? <br> <br>thanks <br> <br>ps. i asked this in another comment, but I'll re-ask here: what purpose do the 2Pin Headers serve? <br>
I just got the kit, and I couldn't get this to work until I changed out the 10K resistor with the other 330 resistor. <br>Troubleshooting was educational, though!
Same here.. I spent over an hour troubleshooting this same project and while I swapped out the resistor for another 10k, I would've never changed to the 330. I was about to pull my hair out and found your comment.. much appreciated.. that leaves some question in my mind as to why this is the case and how someone learning these circuits is supposed to figure something like that out. I love the Arduino but this sparkfun kit has a number of flaws..
The second resistors (560ohm) are listed as also being Red-Red-Red just like 2.2KOhm ones, Probably should read Green-Blue-Brown
This seems like a great kit, but I still cant understand how to make the motor run both ways.. Did anybody manage and is it at all possible?<br>I am also planning to combine several to contol 5 motors. Did anybody try that yet?<br><br>I will be very greatful for your help!<br><br>Pink
how can you make the motor run in forward and reverse? is there a series of code that I can type in, or is it all in how I plug it up? thanks, Andrew
Interesting. I just bought an Osepp board whih is allegedly compatible with the sparkfun arduino.
NEVERMIND- i was using my datasheet for a 2n2222, not the one provided with the link (p2n2222). now i guess i know what that tiny &quot;p&quot; means.
what i thought i knew is now suspect. on the datasheet for the p2n2222ag (and what i thought i already knew) when the flat side of the npn transistor facing me, with a to-92 package,with the pins down, the order from left to right is, emitter, base, and collector on the right. why is this not true on the layout sheet. ?
I tried this out and got it to work. Thanks for the tutorial I learned a thing or two. <br><br>I am however, wondering why the same circuit doesn't work when I replace the 5v and ground from the arduino with a power and ground from a 6v battery pack. Shouldn't it? The motor and transistor are rated for such loads. The only thing I've changed is the power source. I'm trying to make the jump from learning about motor controllers to actually constructing a useful one with it's power independent of the arduinos power.<br><br>I'd appreciate any help any one could point out.
i had a similar problem, where i was powering the arduino and motors from separate power sources.<br><br>It turned out they both had to share the same ground, i just plugged the negative terminal from my battery pack in to the ground rail on my breadboard and then connected a ground pin from my arduino to the same breadboard rail, then everything worked
Thanks for the reply. I've moved on since I posted that but I'll no doubt be reviewing it some day. You might want to post that message in the comments so others can see it and learn.
do i have to press the reset button before uploading new files to arduino uno<br>or i have to erase the older programmes or i just have to upload the new programme
Hello,<br><br>I was reading the datasheet of the 74HC595 and I came across with some values...<br><br>It is written that the max Icc/Ignd is 70mA, and each output pin supports 35mA.<br>If I want, for example, lit 8 leds at the same time, each at 20mA, the total would be 160mA.<br><br>So, wouldnt it damage the 74HC595?<br><br><br>Thanks a lot
ON the in and out code I found an easier way. I reloaded the array so the order is the same order the LEDs are to be lit, then I used loops to kight them from the middle out and unlight them from the outside in. I then changed it around a little to sequence out and then in. <br> <br>Here's the array: <br>int ledPins[] = {5, 6, 4, 7, 3, 8, 2, 9}; <br> <br>Here's the loop: <br>//LEDs light inside to outside <br> for(int i = 0; i &lt;= 7; i++){ <br> int j = i + 1; <br> digitalWrite(ledPins[i], HIGH); //Turns on LED #i each time this runs <br> digitalWrite(ledPins[j], HIGH); //Turns on LED #j each time this runs <br> delay(delayTime); //gets one added to it so this will repeat <br> digitalWrite(ledPins[i], LOW); //Turns off LED #i each time this runs <br> digitalWrite(ledPins[j], LOW); //Turns off LED #j each time this runs <br> } //8 times the first time i will = 0 the final <br> //time i will equal 7; <br> <br>//LEDs light outside to inside <br> for(int i = 4; i &gt;= 0; i--){ //same as above but rather than starting at 0 and counting up <br> int j = i + 1; <br> //we start at seven and count down <br> digitalWrite(ledPins[i], HIGH); //Turns on LED #i each time this runs <br> digitalWrite(ledPins[j], HIGH); //Turns on LED #i each time this runs <br> delay(delayTime); //gets one added to it so this will repeat <br> digitalWrite(ledPins[i], LOW); <br> digitalWrite(ledPins[j], LOW);
void loop() { int value = analogRead(potPin) / 4; analogWrite(ledPin, value); } <br><br>potPin was not decleared in the scope........ everytime i rewrite or copy and paste <br><br>
Hello,<br>This step mentions linking multiple shift registers together to control a larger number of LEDs with just 4 Arduino pins. How is this accomplished? Thanks for your help.
http://www.arduino.cc/en/Tutorial/ShiftOut
Hi there, I am wondering if I can run my dc motor reverse. is there any special code to make it reverse? if there is, please tell me. thank you,
the red wire is normally going in the + rail, pull it out and connect it to the Collector of the transistor and the black wire coming from the motor goes into the + rail
&nbsp;Hey, just thought I'd let you know that the example from arduino.cc uses a pull-down configuration while your circuit uses a pull-up configuration, so the LED on/off is reversed (:
Where is the code for this project? Can't find it anywhere.<br />
The code is just below the video and goes all the way to the right and i mean ALL the way
&nbsp;Hello there, nice job,thanks! Maybe you could help me here.<br /> <br /> I am trying to figure out why is the 2.2k resistor required? I have seen in the transistor datasheet something like &quot;Emitter-Base voltage = 6.0Vdc&quot;, doesn't it mean that we could plug the device directly to Arduino?<br /> <br /> I am trying to figure out if I may use a 2N60B instead, since I have one of these here. I just don't know why would I need a resistor.<br /> <br /> Thanks in advance.<br /> <br /> P.S.: The code appears without line breaking (using google-chrome for Linux) for me.<br />
The &quot;Emitter-Base voltage = 6.0Vdc&quot; statement may be the confusing thing here; The maximum REVERSE voltage that may be applied to&nbsp;the Base-Emitter junction&nbsp;is ~6V But the normal&nbsp;FORWARD drob across the&nbsp;base-emitter junction is approximately 0.7V...&nbsp;&nbsp;The current into the base&nbsp;MUST be limited to prevent the transistor form being distroyed be excessive base current.<br /> <br /> Since the 0.7V forward base voltage is significantly less than the 5V output of the Arduino port pin, then the current flowing into the base of the transistor would&nbsp;likely exceed the rated maximum of both the Arduino&nbsp;pin AND the rated maximum input current od the base of the transistor.<br /> <br /> The function of the resistor is to prevent damage (caused by excessive current) to either the transistor or the Adrion.&nbsp;
&nbsp;Thank you for your attention ;)<br /> <br /> I found the mentioned info in the dataheet. Still I did not understand some details, however. How do I get to the 2.2k value? Am I supposed to assume a 2mA current at the base so that r=v/i=4.3/0.002=2150? How do I get that info in the sheet?<br /> <br /> I am right now using a photocoupler to do the job of swtching the motor, I will make an instructable soon, but I still am not sure about the resistor values.<br /> <br />
If you are using a bipolar transistor (2n2222, 2n3904 etc), read the data sheet...<br /> <br /> 1. determine the current that the transistor must switch and divide it by the Hfe (current gain of the transistor at the desired load current per the data sheet)<br /> <br /> 2. multiply the result by 2 (safety margin)....&nbsp; this is the ideal base current for your application<br /> <br /> 3. subtract 0.7V (the base-emitter drop)&nbsp;from the drive voltage from the Arduino pin&nbsp;(use the data sheet&nbsp;and&nbsp;the Minimum guaranteed Vh out.<br /> <br /> 4. divide this number by the base current you determined in 2 above.<br /> <br /> 5. this is the base resister value you need to use.<br /> <br /> works every time ^_*<br /> <br />
&nbsp;Thanks, that's what I wanted to know: how to determine the base current. Now I know it is obtained by dividing the switched current by the transistor's Hfe.<br /> <br /> Again thanks a lot!<br />