Shop OBEX P1 Docs P2 Docs Learn Events
Bs2 led pwm dim aok — Parallax Forums

Bs2 led pwm dim aok

ercoerco Posts: 20,256
edited 2012-08-27 20:11 in BASIC Stamp
That's all the 3-letter acronyms I could muster...

Someone on another forum was asking about PWMing some LEDs, so I just had to bust out out my HW board and have a go at bit-banging pwm. Simple code is the best! I remember PJ was playing with this a while ago, now I see what all the fun was about. LED illumination isn't perfectly linear, so I had to play with the series resistor to get it to "look right". It looks better in person than on the video.
' {$STAMP BS2}
' {$PBASIC 2.5}
PAUSE 1000
B3=20
a:LOW 0:HIGH 2:LOW 4:HIGH 6
PAUSE 200
FOR B0=0 TO B3
B1=B3-B0
HIGH 0:LOW 2 :HIGH 4:LOW 6
PAUSE B0
LOW 0:HIGH 2:LOW 4:HIGH 6
PAUSE B1
NEXT
HIGH 0:LOW 2 :HIGH 4:LOW 6
PAUSE 200
FOR B0=B3 TO 0
B1=B3-B0
HIGH 0:LOW 2 :HIGH 4:LOW 6
PAUSE B0
LOW 0:HIGH 2:LOW 4:HIGH 6
PAUSE B1
NEXT
GOTO a

Comments

  • ercoerco Posts: 20,256
    edited 2012-08-27 08:49
    Something to shoot for:
  • skylightskylight Posts: 1,915
    edited 2012-08-27 15:21
    That's impressive, how was it achieved? what controller?
  • ercoerco Posts: 20,256
    edited 2012-08-27 15:42
    I used a BS2, of course !

    Oh, you meant the 144 LED guy... :(

    Don't make me do it with a BS2... actually it would be pretty easy to program. Soldering the 144 LEDs would be the hardest part.

    I just got a huge bag of low-current red LEDs, this might just work out.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-08-27 16:27
    erco wrote:
    That's all the 3-letter acronyms I could muster...
    FYI: PLX BS2 (PIC MCU, LDO Reg, +5V Vdd) 5mm red (not RGB) LED PWM dim. IMO, AOK!

    -Phil
  • ercoerco Posts: 20,256
    edited 2012-08-27 19:23
    Wel now yer jus' shn off, Phi ! Nok itt off!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-08-27 19:42
    Sry. Cnt hep msf!

    -P.
  • ercoerco Posts: 20,256
    edited 2012-08-27 20:11
    I should know better than to challenge a guy named PI to a 3-letter word contest...
Sign In or Register to comment.