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

    I connected a 10k resistor from VCC to GPIO.3 and then the button is still connected to GPIO.3 and GND. Push the button, the color changes, but still the same as above.

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    Your LEDs are conected to Vdd instead of GND.
    And GPIO is set to 0, so initially all pins are low at the beginning and thus LEDs are on.
    When a PWM cycle is done, the pin stays low again and the LED is still on.

    I am guessing Steve forgat to add these in his last posted code above.


    Before "pwm ButtonCount,127,100", insert these:
    Code:
    HIGH RED
    HIGH GREEN
    HIGH BLUE

    So the new code will be as below:
    Code:
    MAIN:
     
            IF !SwitchPin THEN                              ' Switch down?
     
                                                            ' - YES
     
                    If ButtonCount = 3 THEN ButtonCount = 0 ' - Currently on GP3 (MCLR)?  If so, pass go, claim 200$ 
     
                    HIGH RED
     
                    HIGH GREEN
     
                    HIGH BLUE       
                    pwm ButtonCount,127,100                 ' - Light Show
     
                    WHILE !SwitchPin : wend                 ' - Spin 'till button is released
     
                    pAUSE 50                                ' - arbitrary debouince delay
     
                    ButtonCount = ButtonCount + 1           ' - Point to next LED
     
                    endif                                   ' 
            GOTO MAIN
    Last edited by sayzer; - 14th August 2011 at 21:05. Reason: typo
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  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 have one RGB LED with a common anode thats hooked up to VDD. The individual pins are connected to the I/O ports on the chip. I entered in the code above but all colors are still on. The even funnier part is i even commented out those lines including the PWM line and all three are still on. I commented out just the PWM line, same thing. I even erased the chip, verified erase and reprogrammed.

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. RGB Led on a PIC10F202

    cmcon0 = 0




    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    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.

  6. #6
    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 01:12.
    Regards,

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

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

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