Simple Blinking LED - WTF!!


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2009
    Posts
    34

    Default Simple Blinking LED - WTF!!

    OK, I've been out of the PIC stuff for about a year now and have noticed some significant brain drain (on my behalf)

    I am just trying to get back into the PICbasic with some simple LED blinking with a 12F683. I looked at some of my old code with controlled 3 LED's and the code (compiled) works just fine. But when I comment out 2 of the 3 LED's, the remaining LED just stays ON.

    The code posted shows only GPIO.1 remaining active...but the LED stays on.

    I know this is peanuts to all of you...but please help me out. I even tried a simple code with a simple loop! Still didn't work.

    John.

    Code:
    osccon = %01100000  ' Ocs set to 4 MHz
    trisio = %00000000  '
    wpu = %00011000 
    'CMCON0 = 7                ' Analog comparators off
    'ANSEL  = 0                ' Analog select set to digital, pg 69 data
    'ADCON0 = 0                ' A/D turned OFF, pg 68 of data
    
    
    
    
    pausetime var word
    Out0 	var gpio.0
    Out1 	var gpio.1
    Out2 	var gpio.2
    B0		var	byte	
    
    ' SET VARIABLES
    	pausetime = 200
    	B0 = 0
    	low 0
    	low 1
    	low 2
    
    
    start:
    
    'button gpio.3,1,10,5,B0,1,notp
    if gpio.3 = 1 then goto start
    
    'call blink0
    'call blink2
    call blink1
    
    
    goto start
    
    
    blink0:
    high out0
    pause pausetime
    low out0
    'pause pausetime
    return
    
    blink1:
    high out1
    pause pausetime
    low out1
    'pause pausetime
    return
    
    blink2:
    high out2
    pause pausetime
    low out2
    'pause pausetime
    return
    
    notp:
    goto start
    
    end

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Hi johnnylynx,
    Change CALL to GoSub
    Call is an asm function - return works with gosub.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Hi johnnylynx,
    Change CALL to GoSub
    Call is an asm function - return works with gosub.
    Hi,

    Thanks for the quick feedback - Question though - why would it work if all three or two CALL lines are active?

    I tried changing the CALL to GOSUB and it still didn't work. If I add a 'PAUSE pausetime' after the LOW command it worked. Found that solution elsewhere!

    Why would it work with out the added PAUSE (with 2 or more CALL's active)?

    Confused I am.

    John.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by johnnylynx View Post
    Hi,

    Thanks for the quick feedback - Question though - why would it work if all three or two CALL lines are active?

    I tried changing the CALL to GOSUB and it still didn't work. If I add a 'PAUSE pausetime' after the LOW command it worked. Found that solution elsewhere!

    Why would it work with out the added PAUSE (with 2 or more CALL's active)?

    Confused I am.

    John.
    Hi John,
    Think about what you are telling it to do,
    Turn light on
    pause 200
    turn light off
    no waiting here
    turn light on
    pause . . . The PIC is faster than the eye.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Jan 2009
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Hi John,
    Think about what you are telling it to do,
    Turn light on
    pause 200
    turn light off
    no waiting here
    turn light on
    pause . . . The PIC is faster than the eye.
    Yep, time for me to get some rest...Can't believe I missed that. Now I can rest peacefully.

    Thanks!

  6. #6
    Join Date
    Jan 2010
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    Don't feel bad, I looked over it and didn't see that either! haha.

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 07:14
  2. Free Project - 245 LED Display
    By T.Jackson in forum Code Examples
    Replies: 221
    Last Post: - 16th August 2009, 05:59
  3. 20 Mhz Crystal, simple blinking LED
    By BenjaminsShinob in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th October 2007, 06:06
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 03:30
  5. simple LED Blinking project
    By koossa in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 11th December 2004, 02: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