Newbie help. RGB Led on a PIC10F202


Results 1 to 40 of 42

Threaded View

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

    Code:
            Red         var GPIO.0
            Green       var GPIO.1
            Blue        var GPIO.2
            SwitchPin   var GPIO.3
            
            ButtonCount VAR BYTE
            ButtonCount = 1
            
            ;Make sure LEDs are off
            HIGH Red 
            HIGH Green
            HIGH Blue
    
    MAIN:
            IF SwitchPin THEN 
                    If ButtonCount = 1 THEN GOSUB RedProgram
                    If ButtonCount = 2 THEN GOSUB GreenProgram
                    If ButtonCount = 3 THEN GOSUB BlueProgram
                    If ButtonCount = 4 THEN ButtonCount = 1
                    ButtonCount = ButtonCount + 1
                    endif
            GOTO MAIN
    
    RedProgram:
            PWM Red,127,100
            RETURN
    
    GreenProgram:
            PWM Green,127,100
            RETURN
    
    BlueProgram:
            PWM Blue,127,100
            RETURN
    Code:
            Red         var GPIO.0
            Green       var GPIO.1
            Blue        var GPIO.2
            SwitchPin   var GPIO.3
            
            ButtonCount VAR BYTE
            ButtonCount = 1
            
            ;Make sure LEDs are off
            HIGH Red 
            HIGH Green
            HIGH Blue
    
    MAIN:
            IF SwitchPin THEN 
                    If ButtonCount = 1 THEN 
                            PWM Red,127,100
                            ENDIF
                    If ButtonCount = 2 THEN 
                            PWM Green,127,100
                            ENDIF
                    If ButtonCount = 3 THEN 
                            PWM Blue,127,100
                            ENDIF
                    If ButtonCount = 4 THEN ButtonCount = 1
                    ButtonCount = ButtonCount + 1
                    endif
            GOTO MAIN
    Last edited by mister_e; - 14th August 2011 at 01:51.
    Steve

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

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