Repeat Blink LED

Goal: Make an LED blink in a continuous loop

Purpose: This will demonstrate the use of the “dira” to set pin to an output state, and then use “outa” to turn on the LED.

Clock frequency: 5,000 Hz

Propeller code type: This propeller code is based on spin language only.

Files to download: (right click)

demo_repeat_blink_led

Pics to Download: (click to enlarge)

Single LED

{{
************************************
*       demo_repeat_blink_led      *
*       2008                       *
************************************

Goal: Make an LED blink in a continuous loop

Purpose: This will demonstrate the use of the "dira" to set pin to an output state,
and then use "outa" to turn on the LED.
}}

CON

_clkmode     = xtal1 + pll16x           ' Feedback and PLL multiplier
_xinfreq     = 5_000_000                ' External oscillator = 5 MHz

pinLED       = 0                        ' assign which pin the led is on

PUB Blinker                               ' Main method

dira[pinLED]~~                          ' Set pin to output (~ sets I/O to input
and ~~ sets I/O to output, all pins default to input state)

repeat                                  ' Endless loop

!outa[pinLED]                          'toggles output of pin low/high (if low,
then high, or if high, then low)

waitcnt(clkfreq / 4 + cnt)            ' Wait 1/4 second -> 2 Hz   (uses the clock
frequency of 5 MHz)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>