Shop OBEX P1 Docs P2 Docs Learn Events
BS2 PO-P15 pins — Parallax Forums

BS2 PO-P15 pins

bluejaybluejay Posts: 131
edited 2013-10-14 16:07 in BASIC Stamp
I have 16 leds connected to vdd and ground. I am trying to turn on all or some leds without assigning every led to each pin, without using coding such as led 0 = pin0,
led 1= pin1, led 2 = pin 2, etc.Then OUT 0 = high, out 1 = high, etc.
There must be a better and shorter way to do this. Maybe using DIRS? Please advise and thanks.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-10-11 19:40
    OUTS is a 16-bit variable that represents all of the I/O pins. You can set OUTS = $F0F0 to make P4-P7 and P12-P15 high and the rest low all at once. The fact that you can do it doesn't make it a good idea. Specifically, there are limits on the amount of current that can be switched or provided by the Stamp. Any single I/O pin can provide up to 20mA. Any 8-bit group (P0-7 and P8-15) can handle up to 50mA. The whole chip can handle 100mA. If you want to turn on any combination of LEDs, that limits the current per LED to about 6mA. Using red LEDs, that would require a 560 Ohm or higher current limiting resistor. Other colors would require different resistor values.

    Remember that you have to set any I/O pins used for LEDs as output pins. You can do DIRS = $FFFF to do this for all the I/O pins.
  • hitolisolohitolisolo Posts: 11
    edited 2013-10-14 12:55
    Mike Green wrote: »
    Specifically, there are limits on the amount of current that can be switched or provided by the Stamp. Any single I/O pin can provide up to 20mA. Any 8-bit group (P0-7 and P8-15) can handle up to 50mA. The whole chip can handle 100mA.

    Version 2.2 of the Stamp Manual says it can only output 40mA per 8-pin group, or 40mA total across all 16 pins if using the internal voltage regulator, yes?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-10-14 16:07
    For that many LEDs I would consider using shift registers. You could simply update a word variable and shift it out to update the display.
Sign In or Register to comment.