Turning on and off a Led using the propeller spin.
Joe
Posts: 184
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
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
Comments
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.
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
See the thread called SPIN CODE EXAMPLES FOR THE BEGINNER.· This has lots of introductory examples, starting with blinking LEDs.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··