Shop OBEX P1 Docs P2 Docs Learn Events
Turning on and off a Led using the propeller spin. — Parallax Forums

Turning on and off a Led using the propeller spin.

JoeJoe Posts: 184
edited 2006-05-06 17:27 in Propeller 1
Hi,

I want to know where can I find a little rutine to understand
how can I turn on and off a led using the propeller.

Using Basic Stamps it is easy just:

' {$STAMP BS2}

ini:

high 4
pause 500
low 4
pause 500

goto ini


How can I do the same using the propeller?
Thanks, Joe

confused.gif

Comments

  • JamesxJamesx Posts: 132
    edited 2006-05-05 23:07
    Check out http://forums.parallax.com/forums/default.aspx?f=25&m=113109

    I don't have a Propeller yet to try it, but that's how it's supposed to work. There's a whole bunch of other interesting examples as well in that same thread.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-06 01:08
    Here's the Spin version of your program:

    PUB main

    · dira[noparse][[/noparse]4] := 1··················· ' make P4 an output
    · repeat························· ' do forever
    ··· outa[noparse][[/noparse]4] := 1················· ' make·P4 high
    ··· waitcnt(clkfreq / 2 + cnt)··· ' wait 1/2 second (500 ms)

    ··· outa[noparse][[/noparse]4] := 0················· ' make P4 low
    ··· waitcnt(clkfreq / 2 + cnt)··· ' wait 1/2 second (500 ms)


    Since the delay is the same for both the high and low portions you can shorten it to this:

    PUB main
    ·
    · dira[noparse][[/noparse]4] := 1··················· ' make P4 an output
    · repeat························· ' do forever
    ··· !outa[noparse][[/noparse]4]····················· ' toggle P4
    ··· waitcnt(clkfreq / 2 + cnt)··· ' wait 1/2 second (500 ms)



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-05-06 17:27
    Hi Joe,

    See the thread called SPIN CODE EXAMPLES FOR THE BEGINNER.· This has lots of introductory examples, starting with blinking LEDs.

    Dave




    Joe said...
    Hi,

    I want to know where can I find a little rutine to understand
    how can I turn on and off a led using the propeller.

    Using Basic Stamps it is easy just:

    ' {$STAMP BS2}

    ini:

    high 4
    pause 500
    low 4
    pause 500

    goto ini


    How can I do the same using the propeller?
    Thanks, Joe

    confused.gif
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··
Sign In or Register to comment.