This is the code and circuitry to control the contrast and backlight via the PIC:
CLEAR
ADCON1 = 7
ASM
@ DEVICE PIC16F877, HS_OSC, WDT_OFF, PWRT_ON, BOD_ON, LVP_OFF, CPD_OFF,
WRT_OFF, DEBUG_OFF, PROTECT_OFF
ENDASM
DEFINE OSC 20
varContrast VAR BYTE
varBacklight VAR BYTE
varContrast = 100
HPWM 1,varContrast,32767
varBacklight = 200
HPWM 2,varBacklight,32767
' Here I have logic to scan 4 input buttons to increase/decrease varBacklight
' and varContast, then I reissue HPWM commands using new values.
END
Robert
![]()
Bookmarks