blinking LED


Closed Thread
Results 1 to 15 of 15

Thread: blinking LED

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    how about the easiest one out there:

    Code:
    Start:
    
    High Porta.1
    
    High porta.0
    Pause 500
    Low Porta.0
    Pause 500                       '1 second
    
    High porta.0
    Pause 500
    Low Porta.0
    Pause 500                       '2 seconds
    
    High porta.0
    Pause 500
    Low Porta.0
    Pause 500                        '3 seconds
    
    High porta.0
    Pause 500
    Low Porta.0
    Pause 500                       '4 seconds
    
    High porta.0
    Pause 500
    Low Porta.0
    Pause 500                       '5 seconds
    
    High porta.0
    Pause 500
    Low Porta.0
    Pause 500                       '6 seconds
    
    Low Porta.1
    pause 1000
    
    goto start
    it might not be the smallest in code size, but it will work and its really easy to understand!!!

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Here is mine.

    No PAUSE used !
    Code:
    @ DEVICE PIC16F628A, INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_OFF, MCLR_OFF,PROTECT_ON,CPD_ON ,BOD_OFF,LVP_OFF
    
    TRISA=0
    TRISB=0
    CMCON=7               ' PortA=digital I/O
    PAUSE 1
    VRCON=0
    PAUSE 1
    
    PORTA=0
    PORTB=0
    
    T1CON=%00110001       ' 0.524ms
    TMR1IF VAR PIR1.0       ' Overflow bit of Timer1.
    
    Output1 VAR PORTA.1     ' Blink 6secs.
    Output2 VAR PORTA.0     ' Blink 0.5secs.
    
    PreLoad     VAR WORD
    TimeCount   VAR BYTE
    TimetoBlink VAR BYTE
    
    PreLoad=3036 ' to get 500ms.
    TMR1L=PreLoad.LowByte
    TMR1H=PreLoad.HighByte
    
    TimeCount=0
    TimetoBlink=12 '12=6secs.
    
    PAUSE 50         ' OSC to Settle.
    
    
    Start:
    
    
       IF TMR1IF THEN Blink
    
       GOTO Start
        
        
    
    Blink: 'Each int is 0.500 sec.
        TMR1L=PreLoad.LowByte   ' Load the timer with preload value.
        TMR1H=PreLoad.HighByte
        TimeCount=TimeCount + 1 ' Count interrupts.
        Output2=Output2 ^ 1     ' Toggle fast blinking output.    
    
        IF TimeCount=TimetoBlink THEN '6Secs ON, 6secs OFF.
          TimeCount=0                   
          Output1=Output1 ^ 1 
        ENDIF
       
        TMR1IF=0                ' Clear TMR1 int. flag.  
        
        GOTO Start    
        
    END    
    
    Last edited by mackrackit; - 8th April 2011 at 06:07. Reason: HTML TO BB
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Simple Blinking LED - WTF!!
    By johnnylynx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st February 2010, 06:19
  2. Blinking an led problem on P16F84
    By aimenbukharie in forum General
    Replies: 1
    Last Post: - 20th March 2009, 05:00
  3. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. simple LED Blinking project
    By koossa in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th December 2004, 01:25

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts