Beginner help!


Closed Thread
Results 1 to 15 of 15

Thread: Beginner help!

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Beginner help!

    Welcome aboard!

    I'm not sure what you want to accomplish. Do you want to make 2 LEDs blink one after another, you just turn the LEDs ON/OFF directly:

    - PIC wired as in PBP manual (section 2.4 in v2.60).
    - have one LED on pin B0 as in example.
    - have another just like it on pin B1.
    - configure your particular PIC properly.
    - define proper oscillator and then do this:

    Code:
    TRISB = %00000000    ' set all Port B pins as output
    
    LED1 = PortB.0           ' assign LEDs to Port B
    LED2 = PortB.1
    
    LOOP:
    
    LED1 = 1                   ' turn ON LED 1
    LED2 = 0                   ' turn OFF LED 2
    PAUSE 100                ' wait a bit so the human eye can catch the blink
    
    LED1 = 0                  ' alternate the LEDs
    LED2 = 1
    PAUSE 100
    
    GOTO LOOP              ' start over
    If you use Port A, there may be other considerations in the configs (section 2.5.1).

    This is off the top of my head. It's not written for optimization, it's written so you can understand easily what is happening.

    If you dig around in your PBP folder, you will find sample programs. I'm not on my programming PC so I can't tell you exactly where. There is a BLINKY example in there already.

    Robert



    EDIT: I don't get it, code comments used to line up properly before....
    Last edited by Demon; - 24th April 2012 at 19:03. Reason: trying to line up the code properly

  2. #2
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Beginner help!

    Well, I sorta agree with the above. Back off a little and try getting a single LED to blink then work your way up. The PBP book talks about some of the peculiarities of the 12F683 so that's a really good place to start.

    But, there isn't a PORTB on a 12F683 so the above won't work.

    If you look, http://www.picbasic.co.uk/forum/showthread.php?t=14511, here it will explain a few ways to blink an LED.

    As far as pin selection, I'd shy away from using pins 3,6 and 7 on the 12F683 if you are doing ICSP. In Circuit Serial Programming (ICSP) allows you to program the PIC without having to remove it from the circuit. If you don't do this you'll have to pull the chip out of circuit, program it then reinsert it in circuit. At any point you can bend a pin or jiggle the circuit. Pin 3 which is Master Clear (MCLR), also pins 6 and 7 which are used for programming Data and Clock. I don't remember which is which. That leaves pin 5 GPIO.2, pin 3 GPIO.4 and pin2 GPIO.5 to put LEDs on. You can attach the Anode of the LED to any of these pins and attach the Cathode to ground.

    This link, http://members.shaw.ca/picgroup/Reso...Cadilly-13.pdf, will get you to a paper that really helps when using the 12F683.

    Best Wishes

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: Beginner help!

    Quote Originally Posted by AvionicsMaster1 View Post
    ...
    But, there isn't a PORTB on a 12F683 so the above won't work.
    Gaaaaa, didn't notice the PIC model.


    Quote Originally Posted by AvionicsMaster1 View Post
    ...
    You can attach the Anode of the LED to any of these pins and attach the Cathode to ground.
    ...

    Don't forget the current limitting resistor, most use 330ohms.


    Side note: I learned basic electronics and PIC programming just by using google. Whenever I was faced with a new component, like a LED, I'd google LED TUTORIAL and found everything I needed to know (anode, cathode, current-limitting resistor, etc).

    When I needed extra help, I'd ask on an Electronic 101 forum:
    http://groups.yahoo.com/group/Electronics_101/

    Robert

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