turn on and off 21 LEDs using BStamp2 P40
Markus
Posts: 22
Hi,
I can't turn on 21 LEDs using this rutine.
Do you know why ? Any easy rutine instead this one?
' {$STAMP BS2p}
' {$PBASIC 2.5}
ini:
FOR W2 = 0 TO 21
HIGH W2
PAUSE 100
LOW W2
PAUSE 100
NEXT
GOTO ini
Thanks, Mark
I can't turn on 21 LEDs using this rutine.
Do you know why ? Any easy rutine instead this one?
' {$STAMP BS2p}
' {$PBASIC 2.5}
ini:
FOR W2 = 0 TO 21
HIGH W2
PAUSE 100
LOW W2
PAUSE 100
NEXT
GOTO ini
Thanks, Mark
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Setup_Pin:
· IOTERM thePin / 16················· · ' point to correct pin bank
· thePin = thePin // 16·············· · ' truncate 'bank' from pin
· DIRS.LOWBIT(thePin) = 1············ · ' make the pin an output
· OUTS.LOWBIT(thePin) =·pinLevel······· '·set the pin level
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
You should probably add 2 ULN2008 darlington chips to the circuit to handle the current for you.
Now, if you're using "High efficiency" LED's, of 1 to 3 mA each, that's below the 50 mA limit for the PIC chip, and you'd be okay.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
If not, then you're right, it's not a problem.
That one is an SX-Ubicom, soon to be an SX-Parallax chip. It actually may handle a bit more power. [noparse][[/noparse]read the specifications]
Alternatively, he can use three shift registers and get 24 leds lit from one data pin, one clock pin, and one latch pin. There are even 'high power output shift registers' that can eliminate the UNL2308.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
· He may not know that, so your post is justified in simply making him aware of this potential problem.· I was just going by the original code posted.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
I was testing the BSP40 with LEDs
Then it seems that Basic Stamp P40 couldn't turn on and off
more than 16 LEDs at the same time.
( Regarding Paul Baker reply )
Thanks for all the support. Mark
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
The current is not my problem.
The problem I have is to use the all the Basic Stamp P40 pins at a time,
something like:
' {$STAMP BS2p}
' {$PBASIC 2.5}
High 1
High 2
High 3
High 4
High 5
High 6
High 7
High 8
High 9
High 10
High 11
High 12
High 13
High 14
High 15
High 16
High 17
High 18
High 19
High 20
High 21
END
Please suppose the I/O consuption is not the problem because I
could use a very little led and the total comsumption of all pins at the
same time is 15 mA only. I that possible?
Thanks, Mark
Main:
· FOR thePin =·1 TO 21
··· pinLevel = 1············ ' make pin high
··· GOSUB Setup_Pin··········' do it
· NEXT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax