Newbie help. RGB Led on a PIC10F202


Closed Thread
Results 1 to 40 of 42

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    16


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    Error[113] c:\pbp\pbppic12.lib 423 : Symbol not previously defined (CMCON0). A have a whole bunch of these.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    The 10F202 doesn't have a CMCON0 register so leave that out.

    See if this works;
    Code:
    @  __config _WDT_OFF & _MCLRE_OFF & _CP_OFF
     
      Red       var GPIO.0
      Green     var GPIO.1
      Blue      var GPIO.2
      SwitchPin var GPIO.3  ' Active low
     
      RD CON %11111110  ' red
      GR CON %11111101  ' green
      BL CON %11111011  ' 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
     
      OPTION_REG = %00000000  ' GPIO.2 for GP use
      TRISIO = %00001000  ' GP3: Input, other pin: Output 
      GPIO = %00000111    ' LEDs off
      ButtonCount = 0
     
    MAIN:
      IF !SwitchPin THEN                         ' Switch down?
         WHILE !SwitchPin : wend                 ' - Spin 'till button is released
         PAUSE 50                                ' - arbitrary debouince delay 
         ButtonCount = ButtonCount + 1
     
         SELECT CASE ButtonCount
           CASE 1 
             GPIO = RD
           CASE 2 
             GPIO = GR
           CASE 3 
             GPIO = BL 
           CASE 4
             GPIO = YL 
           case 5
             GPIO = CY
           case 6
             GPIO = PR
           case 7
             GPIO = WT
           case IS > 7
             GPIO = OF
             ButtonCount = 0
         END SELECT
     
      ENDIF
      GOTO MAIN
      END
    The PWM command returns the output pin to an input after it finishes so that might be causing some funkiness. Try just placing color values on the port and see if this helps.
    Last edited by Bruce; - 15th August 2011 at 00:12.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  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

    Switch works. Just not following the colors you have in each of the case statements. In order of presses in goes: Red, Green,Blue, Yellow for a split second, White, Cyan, Red, No White then cycles over again as it should.

    We are getting closer though and very much appreciate this. This is my first project with any of PIC MCUs as well as my first with PICBASIC Pro.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    My bad. Change the + to & in the color mix constants...;o)

    YL CON GR & RD, etc,,
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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