; --- Flashlight.asm ---- ; This program drives an RGB flashlight based upon the button pressed COLOR equ 0 #include org 0x800 call Init Loop: movf COLOR,W btfsc PORTB,0 ; if RB0 pressed, color = 000 (off) movlw 0 btfsc PORTB,1 ; if RB1 pressed, color = 001 (blue) movlw 1 btfsc PORTB,2 ; if RB2 pressed, color = 010 (green) movlw 2 btfsc PORTB,3 ; if RB3 pressed, color = 100 (red) movlw 4 movwf COLOR ; send the color to PORTC movff COLOR, PORTC goto Loop Init: movlw 0xFF movwf TRISB clrf TRISC movlw 0x0F movwf ADCON1 clrf COLOR return end