Shop OBEX P1 Docs P2 Docs Learn Events
fading leds? — Parallax Forums

fading leds?

meredth78meredth78 Posts: 18
edited 2006-04-20 23:20 in General Discussion
·I am trying to get an led to fade. I have done·it with the BS2, but I cant get it to work with the SX.


BS2:· ---WORKS---
·· ········ FOR pulsecount = 1 TO 255
··········· PWM led2, 255 - pulsecount, 3
··········· NEXT



SX/B: ---NOT WORKING---
··········· FOR pulsecount = 1 TO 255 step 5
··········· PWM led2, 255 - pulsecount
············NEXT


HELP

-meredth78

Post Edited (meredth78) : 4/20/2006 5:01:40 AM GMT

Comments

  • BeanBean Posts: 8,129
    edited 2006-04-20 10:50
    Meredth,
    You cannot use math in the SX/B PWM command.
    You can do it this way...

    FOR pulseCount = 255 TO 1 STEP -5
    · PWM led2, pulseCount, 3
    NEXT
    SX/B is taking 255 as the duty and pulseCount as the duration.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012

    "SX-Video OSD module"·available from Parallax for only·$49.95 http://www.parallax.com/detail.asp?product_id=30015
    Product web site: www.sxvm.com

    Available now! Cheap 4-digit LED display with driver IC·www.hc4led.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
  • meredth78meredth78 Posts: 18
    edited 2006-04-20 22:12
    Thanks. Now I have another question.· With the BS2, when I am in a " do until" loop I can still use my other pins to do other things, kind of like multitasking. How do I 'multitask' like this with the SX/B?

    Post Edited (meredth78) : 4/20/2006 10:34:29 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-20 22:37
    If you've got a working BS2 program you should be able to translate it -- with just a little effort -- to SX/B.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • meredth78meredth78 Posts: 18
    edited 2006-04-20 22:53
    But, I can't get it to "Multitask" like the BS2 is doing.·The SX·gets stuck in the 'do until' loop and won't do anything else when the other pins go high.

    Post Edited (meredth78) : 4/20/2006 11:12:28 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-20 22:56
    The BS2 doesn't multitask; what you can do is create a task-switcher and that is easily done with SX/B. Post your BS2 program and we can give you some hints.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • meredth78meredth78 Posts: 18
    edited 2006-04-20 23:20
    I know it's messy but I'm learning.
Sign In or Register to comment.