Code:
'Port Definitions
RESET VAR PORTB.6
STROBE VAR PORTB.7
'Variables
AD0 VAR WORD ' A to D 1 variable holder
AD1 VAR WORD ' A to D 2 variable holder
RD VAR WORD[7] ' Right ADC value
LD VAR WORD[7] ' Left ADC value
C VAR WORD ' Count variable holder
TRISA = 1111 ' Set as outputs & inputs
TRISB = 000000 ' Set as outputs
LOW RESET
LOW STROBE
'Here is the working code:
REM ============================== LCD Setup ===================================
LCDOUT $FE,$40,$00,$00,$00,$00,$00,$00,$00,$1F ' Bar 1
LCDOUT $FE,$48,$00,$00,$00,$00,$00,$00,$1F,$1F ' Bar 2
LCDOUT $FE,$50,$00,$00,$00,$00,$00,$1F,$1F,$1F ' Bar 3
LCDOUT $FE,$58,$00,$00,$00,$00,$1F,$1F,$1F,$1F ' Bar 4
LCDOUT $FE,$60,$00,$00,$00,$1F,$1F,$1F,$1F,$1F ' Bar 5
LCDOUT $FE,$68,$00,$00,$1F,$1F,$1F,$1F,$1F,$1F ' Bar 6
LCDOUT $FE,$70,$00,$1F,$1F,$1F,$1F,$1F,$1F,$1F ' Bar 7
LCDOUT $FE,$78,$0E,$0A,$0A,$0A,$0A,$0A,$0A,$0E ' Bar over
LCDOUT 254,1 ' Clear display
REM ============================== Main loop ===================================
Main:
GOSUB EQread
GOSUB Display
PAUSE 10
GOTO Main
REM ============================= MSGEQ7 code ==================================
EQread:
HIGH RESET 'Reset
HIGH STROBE
PAUSEUS 100
LOW STROBE
PAUSEUS 100
LOW RESET
HIGH STROBE
PAUSEUS 100
FOR C=0 TO 6 'Read
LOW STROBE
PAUSEUS 100
ADCIN 0,AD0
RD[C]=AD0
ADCIN 1,AD1
LD[C]=AD1
HIGH STROBE
PAUSEUS 100
NEXT C
LOW STROBE
RETURN
REM =============================== Display ====================================
Display:
FOR C=0 TO 6
RD[C]=RD[C]/8192
LD[C]=LD[C]/8192
IF RD[C]=0 THEN
RD[C]=$20
ELSE
RD[C]=RD[C]-1
ENDIF
IF LD[C]=0 THEN
LD[C]=$20
ELSE
LD[C]=LD[C]-1
ENDIF
NEXT C
LCDOUT 254,129,LD[0],LD[1],LD[2],LD[3],LD[4],LD[5],LD[6]," ",RD[0],RD[1],RD[2],RD[3],RD[4],RD[5],RD[6] ' Display output on line 1
RETURN
END
Bookmarks