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

    That's an easy way to check if the value is 0. It means if switch is not 1.....
    Alternately, if switch means if switch =1 then. ....
    -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

    Well guys, things are working great so i more than thank you all for your wonderful help. This has been an experience for me and will continue to be as I convert all the code for this 10f202 to a 16f684. I wanted the EEPROM to store the state of the color after every change of color (after 10 seconds of on the same color so as to prevent excessive writes), so when the circuit comes back on again, it will grab the value from EEPROM. I also wanted the hardware PWM to control the LED color.

  3. #3
    Join Date
    Aug 2011
    Posts
    16


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    I think for the most part i have been able to successfully port it, except that the SwitchPin does not work properly on the 16F684. My code is below:

    Code:
    SwitchPin var PORTA.2  ' Active low
     
    RD CON %00010010  ' red
    GR CON %00110000  ' green
    BL CON %00100010  ' blue
    YL CON GR & RD      ' green + red = yellow
    CY CON GR & BL      ' green + blue = cyan
    PR CON BL & RD      ' blue + red = purple
    WT CON GR & BL & RD   ' green + blue + red = white
    OF con %11111111  ' all LEDs off
     
    ButtonCount VAR BYTE
    ButtonCount = 0
    
    PORTC = %00111010    ' LEDs off 
    TRISC = %00000010  ' PC2: Input, other pin: Output 
     
    MAIN:
      IF !SwitchPin THEN
         WHILE !SwitchPin
            pAUSE 200
         wend
         ButtonCount = ButtonCount + 1
     
         SELECT CASE ButtonCount
           CASE 1 
             PORTC = RD
           CASE 2 
             PORTC = GR
           CASE 3 
             PORTC = BL 
           CASE 4
             PORTC = YL 
           case 5
             PORTC = CY
           case 6
             PORTC = PR
           case 7
             PORTC = WT
           case IS > 7
             PORTC = OF
             ButtonCount = 0
         END SELECT
     
      ENDIF
      GOTO MAIN
      END
    I hope its something simple like my TRIS or PORT registers. Thanks much.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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