blinking LED


Results 1 to 15 of 15

Thread: blinking LED

Threaded View

  1. #7
    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