A Different Approach (317 Words ... without most of Darrel's amazing methods, which means there is room for more codesavings)
Code:
;@__config _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
CMCON=%00000111
DEFINE DEBUG_BAUD 2400 'Debug baud rate
DEFINE DEBUGIN_REG PORTB 'Debugin pin port
DEFINE DEBUGIN_BIT 0 'Debugin pin bit
DEFINE DEBUGIN_MODE 1 'Debugin mode: 0 = True, 1 = Inverted
;DEFINE OSC 4
xB0 var byte ; SERIAL IN IS A BYTE SO MAKE IT A BYTE
;inputData var word ' variable to receive data into
' START OF MAIN PROGRAM
'
CMCON = 7 ' RA0-RA3 are digital I/O
TRISA = 0 ' PORT A is output
TRISB = 1 ' RB0 is Input others output
MAIN:
DEBUGin [xB0]
;B0 = 100 * B0 ; why do these two lines? B0 is already a Byte so work with Bytes
;Uin = B0 / 207 ;
LCDOUT $FE, 1
If xB0 < 21 then
LCDOUT "TOO LOW"
GOTO OUT
ENDIF
IF xB0 < 34 then BARGRAPH1
IF xB0 < 42 then BARGRAPH2
IF xB0 < 52 then BARGRAPH3
IF xB0 < 63 then BARGRAPH4
IF xB0 < 73 then BARGRAPH5
IF xB0 < 92 then BARGRAPH6
IF xB0 < 112 then BARGRAPH7
IF xB0 < 131 then BARGRAPH8
LCDOUt $FE, $C0
IF xB0 < 152 then BARGRAPH9
IF xB0 < 170 then BARGRAPH10
IF xB0 < 181 then BARGRAPH11
IF xB0 < 191 then BARGRAPH12
IF xB0 < 201 then BARGRAPH13
IF xB0 < 210 then BARGRAPH14
IF xB0 < 220 then BARGRAPH15
IF xB0 < 230 then BARGRAPH16
LCDOUT $FE,$C0,"TOO RICH"
goto OUT
BARGRAPH16:
gosub p255
BARGRAPH15:
gosub p255
BARGRAPH14:
gosub p255
BARGRAPH13:
gosub p255
BARGRAPH12:
gosub p255
BARGRAPH11:
gosub p255
BARGRAPH10:
gosub p255
BARGRAPH9:
gosub p255
LCDOUT $FE, $80 ; line 1
BARGRAPH8:
gosub p255
BARGRAPH7:
gosub p255
BARGRAPH6:
gosub p255
BARGRAPH5:
gosub p255
BARGRAPH4:
gosub p255
BARGRAPH3:
gosub p255
BARGRAPH2:
gosub p255
BARGRAPH1:
gosub p255
OUT:
Pause 5
goto MAIN
p255:
lcdout 255
return
END ' End of program
[disclaimer] untested [/disclaimer]
Bookmarks