need led blink program


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Mar 2014
    Location
    Pakistan
    Posts
    19


    Did you find this post helpful? Yes | No

    Default Re: need led blink program

    hi,henric thanks for replying ,i tried ur programm but its not working ,i guess i could not describe my requirement clearly,let me explain again ,
    here i have this simple led blink programm and in this program led on portb.7 is blinking endlessly with the pause of 500ms
    now i want another led to blink on portb.6 with pause of 1000 ms ,along with the led which is already blinking with pause of 500ms on portb.7 , both led on portb.6 and portb.7 should blink endlessly but different speed.
    I dont need this programm in any project i am just trying to learn ,Thankyou ,i hope now i have made my requirement clear

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: need led blink program

    Hi,
    Really, is "It's not working" the best description you can come up with?
    What's "not working"? What DOES it do? What DOESN'T it do?

    In your original post you said PortB.0 and 30seconds, PortB.2 and 1 minute, PortB.3 and 2 minutes.....
    Now you're saying PortB.7 and 500ms, PortB.6, 1000ms.... So, no you probably didn't explain your requirements very well.

    I've now tried my previously posted code and it works just fine as per your original specifications. I then changed it to match the revised specification, tested it again at it works just fine here. I'll post it here again:
    Code:
    ' Specify delay time in units of 100ms. 10=1second, 25=2.5seconds etc
    LED1_Time CON 5	    ' 0.5 seconds
    LED2_Time CON 10	' 1 seconds
    LED3_Time CON 30	' 3 seconds
    
    LED1_Count VAR BYTE	' Timekeeping variables
    LED2_Count VAR BYTE
    LED3_Count VAR BYTE
    
    LED1 VAR PortB.7	' Pin aliases for the LEDs
    LED2 VAR PortB.6
    LED3 VAR PortB.5
    
    TRISB = %00011111
    
    Start:
       
        ' Preload timekeeping variables
    	LED1_Count = LED1_Time
    	LED2_Count = LED2_Time
    	LED3_Count = LED3_Time
    
    Main:
    	' Decrement counters
    	LED1_Count = LED1_Count - 1
    	LED2_Count = LED2_Count - 1
    	LED3_Count = LED3_Count - 1
    
    	' Time for LED1 to toggle?
    	IF LED1_Count = 0 THEN
    		TOGGLE LED1
    		LED1_Count = LED1_Time        ' Reload counter for next period.
    	ENDIF
    
    	'Time for LED2 to toggle?
    	IF LED2_Count = 0 THEN
    		TOGGLE LED2
    		LED2_Count = LED2_Time        ' Reload counter for next period.
    	ENDIF
    
    	' Time for LED3 to toggle
    	IF LED3_Count = 0 THEN
    		TOGGLE LED3
    		LED3_Count = LED3_Time        ' Reload counter for next period.
    	ENDIF
    
    	PAUSE 100
    GOTO Main
    Now, I've tested this on another device than what you're using so it's possible that there's something device specific that needs to be set. If you can't get this to work then please describe what it does or doesn't do and post your complete code.

    /Henrik.

Similar Threads

  1. 18F2550 and Blink Led
    By nuno106 in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 21st September 2022, 12:01
  2. Led blink and interrupt
    By critix in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th April 2012, 11:31
  3. Novice 16F83A BLINK LED program help
    By owali in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 25th July 2007, 05:02
  4. Blink.bas Program
    By merlinknight in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th March 2007, 17:42
  5. Can't get a 12F629 to blink a led
    By Sharky in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th June 2005, 11:28

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