Shop OBEX P1 Docs P2 Docs Learn Events
Blinking led with counter - Page 2 — Parallax Forums

Blinking led with counter

2»

Comments

  • Don MDon M Posts: 1,652
    edited 2014-04-03 03:55
    I made some changes using what was posted earlier and I get some blinking. Not quite what I thought it might be but I'll add a back to back LED combo later and see what happens.

    Here's my code:
    PUB Main
    
    ''  examples:
    ''  20,10,0 red, green, pause, repeat
    ''  10,20,0 green, red, pause, repeat
    ''  20, 60,0 red,pause,green,pause, repeat
    ''  20,80,0 red,red,green,green,pause,repeat
    ''  80,20,0 green,green,red,red,pause,repeat
    ''  10,110,00 5 green,5 red, repeat
    ''  10,130,00 6 green,6 red, repeat
    
    ''  Play with both small integer ratios and as also larger numbers to achieve smooth effects.
    ''  The third parameter, the starting phase (in percent from 0 to 99%), adds a measure of syncopation. 
      repeat
        autoFlash(10, 110, 0)
    
    
    PUB autoFlash(frqR, frqG, phsG)
    
      dira[redK..grnK]~~
      
      ctra := constant(%0_00100_000 << 23) | redK 
      ctrb := constant(%0_00100_000 << 23) | grnK 
      phsb := (posx / 100 * phsG) << 1              '
      frqa := frqR                '
      frqb := frqG
      
    
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-04-03 08:01
    The LEDs on the quickstart are connected to ground and individual Prop pins, via a 74HC541 buffer chip. The counters are not playing against one another. Do try it with side to side LEDs as in my diagram. Or even one LED and a regular diode.

    Your two programs have a problem too. The first one will end right after the autoflash, the second one has the repeat, but it is in the wrong place. Here the call to autoflash starts the autonomous counters, and then the repeat keeps the cog alive.
    PUB main
      autoFlash(20, 80, 0)
      repeat
    
    
Sign In or Register to comment.