Newbie help. RGB Led on a PIC10F202


Closed Thread
Results 1 to 40 of 42

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    Ok, new test for you to try. First make sure all three PWM's are working.Let you main call them 1 at a time like this:
    Code:
    main:
    gosub red
    gosub blue
    gosub green
    goto main
    I know you said in your first post that all three worked, lets just be sure, then we can build on that .
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Aug 2011
    Posts
    16


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    Quote Originally Posted by cncmachineguy View Post
    Ok, new test for you to try. First make sure all three PWM's are working.Let you main call them 1 at a time like this:
    Code:
    main:
    gosub red
    gosub blue
    gosub green
    goto main
    I know you said in your first post that all three worked, lets just be sure, then we can build on that .
    Works perfectly. Didnt work at first, but then i forgot the OPTION_REG.5 = 0 had to be put into the code for GPIO.2 to work.

  3. #3
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    Does the whole thing work, button and everything?
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  4. #4
    Join Date
    Aug 2011
    Posts
    16


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    No just the code that you asked me to try.

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    Now let's make sure that button is working. Modify the main to be this:
    Code:
    main:
    Gosub red
    If button =1 then goto skipgreen
    Gosub green
    Skipgreen:
    Gosub blue
    Goto main
    That should have all three lit as before unless you press the button, then it should skip the green gosub. Btw, is the tris for the button set to input? Also I am a lazy typer, so I assume you will make the names be what they need to be like button shoud really be switchpin (i think)
    Last edited by cncmachineguy; - 14th August 2011 at 03:52.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Aug 2011
    Posts
    16


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    Im not sure how to set tris on GPIO.3 I assumed because the datasheet says its an input only pin, i didnt have to futz with it. When i run your code above, i get Red, Green, Back to Red. If i tap the switch, the whole circuit turns off and stays off while i hold it. I never see blue.

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    Well thats just wierd that it skips blue always. but the the whole circuit turning off makes perfect sense. If you look at the gp3 pin, it is input only because it is shared with MCLR. that is the external reset pin. Since you have no configs listed, I assume you are using the defaults. I went and looked at 10f202.inc in the PBP folder and the default config has MCLR_ON. this means GP3 is set to be the reset when low. so I am sure you are reseting the chip, or at least not looking at it as an input.

    2 choices here: Assuming you are NOT using PBP3, you can change the .inc file to MCLR_OFF and leave it as that, or you can comment the configs all together and put them in your code;

    If you are using PBP3, you can use the brand new #config block format and set your configs in your code

    BTW, I am going to assume the blue not working may have something to do with the MCLR issue for now. Also I guess you are right about the TRIS, but I would get in the habit of just ALWAYS setting it. Life will be easier later for you that way.

    Last edit: Please post your current code now so we know where you are.
    Last edited by cncmachineguy; - 14th August 2011 at 04:13.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 1

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