So I want to read data from the A/D potentiometer and then display the status of the voltage on a 8*8 matris led. The idea is to use a column of the 8*8 and display the value there (0-7)
So, the A/D goes from 0-255 but I want to have 0-7 from that, I need to left justify the value?
Nothing works for me and I don't even know if I am doing anything correctly. Any help would be nice
So, the A/D goes from 0-255 but I want to have 0-7 from that, I need to left justify the value?
Nothing works for me and I don't even know if I am doing anything correctly. Any help would be nice
Code:
MAIN CLRF TRISD
CLRF PORTD
CLRF TRISA,RA1
CLRF TRISA,RA1
MOVLW B'000000001';ADCON0 setup: Use AN0, activate ADC-Module
MOVWF ADCON0
MOVLW B'00001110';ADCON1 setup: VSS,VDD ref. AN0 analog only
MOVWF ADCON1
MOVLW B'00010010' ;ADCON2 setup: Left justified
MOVWF ADCON2
MAINL
BSF ADCON0,1
SAMPLE BTFSC ADCON0,1
GOTO SAMPLE
MOVLW ADRESH
MOVWF ADRESH
MOVWF PORTD
BSF PORTA,RA1; Turn on LED
CALL DELAY
BCF PORTA,RA1 ; Turn off LED
GOTO MAINL ;Restart
DELAY MOVLW 0xFF
MOVWF VBA
LOOP2 MOVLW 0xFF
MOVWF VBB
LOOP1 DECFSZ VBB,1
GOTO LOOP1
DECFSZ VBA,1
GOTO LOOP2
RETURN