New At PIC's, need some help with code


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    SOHCKing03's Avatar
    SOHCKing03 Guest

    Default New At PIC's, need some help with code

    Hi everyone,

    I am currently in the works of making a car product where I need to make LED's sequence down a line. i.e 0=off 1=on so...

    0000
    1000
    1100
    1110
    1111
    0111
    0011
    0001
    0000

    I think I have come up with a good code but I don't know how to increment the PIN number in my code during a DO LOOP. Each LED is driven by one output and so I need to increment the outputs to sequence them. Will I have turn on the LED from one output in one LOOP then do another in another LOOP and so on?

    If I'm not clear then I'll try to explain it better.

    -Brad

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


    Did you find this post helpful? Yes | No

    Default

    Hi Joe,

    Take a look at this.

    http://www.picbasic.co.uk/forum/showthread.php?t=3753



    Regards.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    BRAD,

    What PIC? You posted in the PBC section and not PBP - is this correct? If you are using PBC, try

    Code:
    'Example for 16F628A with PBC (Not PBP)
    
    POKE $86, 0	' all of PORTB output (optional line but good programming practice) 
    POKE $06, 0	' all of PORTB low (optional line but good programming practice) 
    
    MAIN:
    PAUSE 500     ' no LED on
    
    FOR B0 = 0 to 3
         HIGH B0      ' turn ON  RB0, then RB1, then RB2, then RB3
         PAUSE 500 ' pause half a second
    NEXT B0
    
    FOR B0 = 0 to 3
         LOW B0      ' turn OFF  RB0, then RB1, then RB2, then RB3
         PAUSE 500 ' pause half a second
    NEXT B0
    
    PAUSE 500     ' no LED on
    
    GOTO MAIN
    
    END
    You might also want to check out Melanie's excellent post here

    http://tinyurl.com/gpt6b

    and search the forum for "rider" (as in knight rider) for more visual ideas.

    Any questions?
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    SOHCKing03's Avatar
    SOHCKing03 Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the replies...

    I think I will test out a code I created using some of the elements from the code you guys gave me...

    Hopefully it'll work and I can get this thing going...

    -Brad

  5. #5
    SOHCKing03's Avatar
    SOHCKing03 Guest


    Did you find this post helpful? Yes | No

    Default

    Okay well I will use the code from the link Sayzer gave me...

    I am making an LED Underbody Kit though and so one PIC will control the front left, one will control the left side, one will control the the back left, and the same for the right side. So I will need my PIC's to communicate. When the last LED on the front left is turned on I want the side to start sequencing and same goes for the transition from side to back.

    To do this will I have to set the final output on the front left to go high and then have it connected to an input on the side PIC? That way I could tell the side PIC not to do anything until that input receives a "high" signal from the other PIC. I could do that correct? If so, how would I program it?

    Thanks again for all your help guys.

    -Brad

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


    Did you find this post helpful? Yes | No

    Default

    If I understood correct, this should be it. Just an example though.



    Code:
    Wait:
    
    IF PORTA.1 = 1 THEN GOTO Loop
    'This is the pin you get the input signal from the other PIC.
    
    GOTO Wait
    
    
    Loop:
    
    'Your loop code should be here....
    'When the last loop index is achieved, 
    'you will HIGH a pin to activate the next PIC
    'and you will go back to "Wait"
    
    
    GOTO loop
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. decoding quadrature encoders
    By ice in forum mel PIC BASIC Pro
    Replies: 93
    Last Post: - 28th February 2017, 09:02
  2. Nokia COLOR LCD PicBasicPro 2.50a example code
    By skimask in forum Code Examples
    Replies: 49
    Last Post: - 28th September 2011, 01:43
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. Code: Why is this code greater than 2000 words?
    By DrDreas in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 1st June 2007, 19:51
  5. Writing code for battery operated projects
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th June 2005, 03:39

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