Newbie help. RGB Led on a PIC10F202 - Page 2


Closed Thread
Page 2 of 2 FirstFirst 12
Results 41 to 42 of 42
  1. #41
    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.

  2. #42
    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