I have already checked it out and others.. the problem is putting the temp reading on LED
************************************************** ******
DEVICE 16F72
DEFINE osc 4 ' 4 MHz oscillator
DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation
DEFINE ADC_CLOCK 1 ' Set A/D clock Fosc/8
DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
Dim digit As Byte 'input variable for GETMASK subroutine
Dim digit1 As Byte 'current digit1
Dim digit2 As Byte 'current digit2
Dim mask As Byte 'output variable from GETMASK subroutine
Dim mask1 As Byte 'current digit1 mask
Dim mask2 As Byte 'current digit2 mask
Dim temp As Word 'Temperature storage
Dim samples As WORD ' Multiple A/D sample accumulator
Dim sample As BYTE ' Holds number of samples to take
Symbol d1enable = PORTC.7 'enable line for display1
Symbol d2enable = PORTC.6 'enable line for display2
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00000011 ' Set PORTA.0,1,2,5 = A/D, PortA.3 = +Vref
TRISB = %00000000 'set PORTB pins as outputs
TRISC.7 = 0 'set RD4 pin as output
TRISC.6 = 0 'set RD5 pin as output
LOW d1enable
LOW d2enable
mask1 = 0 ' Clear samples accumulator on power-up
mask2 = 0 ' Clear samples accumulator on power-up
samples = 0 ' Clear samples accumulator on power-up
PAUSE 250 ' Wait .5 second
loop:
FOR sample = 1 TO 20 ' Take 20 samples
ADCIN 0, temp ' Read channel 0 into temp variable
samples = samples + temp ' Accumulate 20 samples
PAUSE 250 ' Wait approximately 1/4 seconds per loop
NEXT sample
temp = samples/20
digit1 = temp / 10 'get current digit1
temp = temp // 10
digit2 = temp 'get current digit2
digit = digit1
Gosub getmask 'get mask for digit1
mask1 = mask
digit = digit2
Gosub getmask 'get mask for digit2
mask2 = mask
Gosub show1 'display new mask
Gosub show2 'display new mask
pause 500
samples = 0 ' Clear old sample accumulator
Goto loop
End
getmask: 'get appropriate 7-segment mask for input digit
mask = Lookupl digit,[$40,$79,$24,$30,$19,$12,$02,$78,$00,$18], digit
Return
show1: 'show digit1 on its display
LOW d1enable
LOW d2enable
PORTB = mask1
HIGH d1enable
Return
show2: 'show digit2 on its display
LOW d1enable
LOW d2enable
PORTB = mask2
HIGH d2enable
Return
************************************************** *******
Someone please check the above and let me know if there is any errors...?
Cheers
Mastero
Bookmarks