Shop OBEX P1 Docs P2 Docs Learn Events
Powering Leds — Parallax Forums

Powering Leds

manwithgun0100manwithgun0100 Posts: 2
edited 2008-12-19 20:59 in BASIC Stamp
I don't know where i should post this. Let me know if its in the wrong spot.
I'm working on a Christmas project using a gingerbread house, leds, and the Basic Stamp HomeWork Board. I thought about soldering together about 10-20 leds with a 470K resistor for the Christmas lights and running it using the code below. I used 3 leds and the beeper to troubleshoot with and it work pretty good.

Any help would be appreciated. smile.gif


' {$STAMP BS2}
' {$PBASIC 2.5}
' Ginger Bread House Music Code 2008
' Created by manwithgun4

'Song 1 - Jingle Bells

l2 CON 2500
l23 CON 13000
l3 CON 10000
l32 CON 7000
l4 CON 5000
i VAR Word
DO
IF IN13 = 1 THEN
FOR i = 0 TO 1
LOW 0
FREQOUT 9, 100, l3 :HIGH 14
PAUSE 150 : LOW 14
FREQOUT 9, 100, l3 :HIGH 14
PAUSE 150 : LOW 14
FREQOUT 9, 150, l3 :HIGH 14
PAUSE 300 : LOW 14
FREQOUT 9, 100, l3 :HIGH 14
PAUSE 150 : LOW 14
FREQOUT 9, 100, l3 :HIGH 14
PAUSE 150 : LOW 14
FREQOUT 9, 150, l3 :HIGH 14
PAUSE 300 : LOW 14
FREQOUT 9, 100, l3:HIGH 14
PAUSE 150 : LOW 14
FREQOUT 9, 100, l2 : HIGH 1
PAUSE 150 :LOW 1
FREQOUT 9, 100, L4 : HIGH 0
PAUSE 150 : LOW 0
FREQOUT 9,100, L32 : HIGH 0 :HIGH 1 : HIGH 14
PAUSE 150 : LOW 0 :LOW 1 : LOW 14
PAUSE 20
HIGH 1 : FREQOUT 9,400, l3
PAUSE 150 : LOW 1
FREQOUT 9,100, L23 :HIGH 0
PAUSE 150 :LOW 0
FREQOUT 9,100, L23 :HIGH 0
PAUSE 150 :LOW 0
FREQOUT 9,100, L23:HIGH 0
PAUSE 150 :LOW 0
FREQOUT 9,100, L23:HIGH 0
PAUSE 150:LOW 0
FREQOUT 9,100, L23:HIGH 0
PAUSE 150 :LOW 0
FREQOUT 9,100, l3:HIGH 1
PAUSE 150 :LOW 1
FREQOUT 9,100, l3:HIGH 1
PAUSE 200:LOW 1
FREQOUT 9, 300, l3:HIGH 1
PAUSE 150 :LOW 1
FREQOUT 9,100, l3:HIGH 1
PAUSE 150:LOW 1
FREQOUT 9,100, L32:HIGH 14
PAUSE 150 :LOW 14
FREQOUT 9,100, L32:HIGH 14
PAUSE 150 :LOW 14
FREQOUT 9,100, l3:HIGH 1
PAUSE 150:LOW 1
HIGH 14 :FREQOUT 9,400, L32
PAUSE 155 : LOW 14
HIGH 0:HIGH 1: HIGH 14 :FREQOUT 9,400, 9000
PAUSE 150 :LOW 1
NEXT
ELSE
DO WHILE IN13 = 0
HIGH 0
PAUSE 300
LOW 0: HIGH 1
PAUSE 300
LOW 1: HIGH 14
PAUSE 300 :LOW 14
LOOP
ENDIF
LOOP

Post Edited (manwithgun0100) : 12/19/2008 8:40:36 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-19 20:59
    I guess I'm confused about what you plan to do. In particular, how do you plan to connect the LEDs? The HomeWork Board has 16 I/O pins and you need one for the beeper. Do keep in mind that the Stamp can only provide about 20mA on I/O pins 0-7 and another 20mA on I/O pins 8-15. Using a 470 Ohm resistor in series with each LED, you could have 2 LEDs on at a time for each group of 8 I/O pins. If 15 LEDs is enough, you should be fine.

    You may want to power the HomeWork Board from an AC adapter. If you're lighting 4 LEDs at a time, that will exhaust a 9V alkaline battery in maybe 2-4 hours.
Sign In or Register to comment.