Home Chapter 8 BS2 Ohm’s Law Applied to Multiple Pins

Site Search


Chinese (Simplified) French German Italian Portuguese Russian Spanish
BS2 Ohm’s Law Applied to Multiple Pins

In this lesson you will use Ohm’s law to calculate the values of the resistors you will need to protect the microprocessor as you power eight LEDs, instead of one and two LEDs, as in Chapter 7.

You will then build the circuit using a new part called a bar resistor and program the output pins to create sequences of on and off states for the eight LEDs. You will be using binary to write high and low commands directly to the pins. After this, you will add a micro switch to the circuit and program the circuit to allow different sequences to be manifested in relation to pressing or not pressing your input switch.

In this lesson, you will also learn about the PBASIC phrase DIRS, which is to set the direction of your microprocessor pins to be set as inputs and/or outputs.

You will also be using the PBASIC phrase OUTS, which will allow you to use binary to switch the individual pins to a high or low, which will allow you turn the LEDs on and off in the sequences you program.

While each individual pin of the BASIC Stamp can source 25 mA and sink 20 mA, by exceeding either the source or sink of the BASIC Stamp, you can damage the tiny wires on the interior of the microcontroller. There are also limits to how much current multiple pins can source and sink at the same time.


Source is the amount of current available to drive a device from the BASIC Stamp.

Sink is the amount of current the pin can absorb before damage is done.


Pins P0-P7 or P7-P15 should not exceed 50 mA sink and 40 mA source total. So, a series of pins has specific source and sink capabilities, which must be acknowledged in your design.

  1. Using Ohm’s law, calculate what size resistor you would need to limit the Stamp to source only 40 mA total for all eight output pins.
  2. Remember, Ohm’s law states: V = I X R, or voltage = current times resistance. We already know that we have 5 volts DC available on the BS2.

    Solving for resistance:

    We first need to convert mA into amps by moving the decimal place three spaces to the left. So, 40 mA = .04 A.

    Now, divide .04 A by 8. This gives us .005 A, or 5 mA available per pin when driving all 8 pins simultaneously.

    Plug these values into Ohm’s law to get the resistor value needed at each pin. 5 V = .005 A ´ R. Solving for resistance, the Ohm’s law equation now becomes R = V/I, or R = 5/.005, which equals 1000 ohms. 1000 ohms is equal to 1K ohms.

  3. Now that you have figured out your resistor values you are ready to build the circuit. You will be using a new part called the bar resistor with 9 resistors inside one single unit.
  4. Introducing a New Part

    Single In-Line Package (SIP) resistor networks are packs of 8 or 9 resistors or more in a single unit with 10 pins. One of the pins is the common pin that is shared by all the resistors. As with other resistors, SIP resistor networks also have maximum ratings for how much mA they can absorb as heat. The one provided in the kit is a 1/4 W resistor pack. This is a valuable part because it can reduce the chance of accidental short circuits on your board by reducing the number of parts and wires exposed to other parts.


    Bar resistor
    Bar resistor schematic symbol

    Parts Required

    1- 1K ohm SIP resistor network, 1/4 W resistor Jameco #97877 or multiple single 1k ohm resistors
    8 LEDs
    1 9 volt battery or wall transformer connected to the Board of Education
    Jumper wires

    Building the Circuit


    showing the LEDs in a row.

    Schematic of circuit

    Schematic of the circuit