Code:
; working variant ; anode to portB, catode to portA
@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_off
define osc 4
INTCON = 0
TRISA = %00000000
TRISB = %10000000
CMCON = 7 ' Disable comparators
DQ var PortB.7
'***************************************************************************************
eeprom 0, [%10100001,%01111010,%01110110,%01101110,%10100001] '0
eeprom 5, [%11111111,%01111101,%00000000,%01111111,%11111111] '1
eeprom 10,[%01111101,%00111110,%01101110,%01110110,%01111001] '2
eeprom 15,[%10111101,%01111110,%01110110,%01110110,%10101001] '3
eeprom 20,[%11100111,%11101011,%11101101,%00000000,%11101111] '4
eeprom 25,[%10111000,%01111010,%01111010,%01111010,%10100110] '5
eeprom 30,[%10100001,%01110110,%01110110,%01110110,%10101101] '6
eeprom 35,[%11111110,%00001110,%11110110,%11111010,%11111100] '7
eeprom 40,[%10001001,%01110110,%01110110,%01110110,%10001001] '8
eeprom 45,[%11111001,%01110110,%01110110,%01110110,%10001001] '9
counter var byte
scan var byte
scroll var byte
leddata var byte[36] 'Column Data for display 36 columns
temperature var Word 'reading from sensor
Sign var BIT
tempA var byte 'Stores First digit (High)
tempB var byte 'stores Second digit (Mid)
tempC var byte 'stores Third digit (low)
n var byte
DS18B20_12bit CON %01111111
START:
CLEAR 'Clear all varibles
' Init Sensor 1
OWOUT DQ, 1, [$CC, $4E, 0, 0, DS18B20_12bit]
OWOut DQ, 1, [$CC, $48] ' Start temperature conversion
OWOut DQ, 1, [$CC, $B8]
OWOut DQ, 1, [$CC, $BE]
Pause 50
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Pause 50
for n=0 to 7
leddata [n] = %11111111
next n
leddata [13] = %11111111
leddata [19] = %11111111
leddata [20] = %00111111 ' DECIMAL POINT
leddata [21] = %00111111
leddata [22] = %11111111
leddata [28] = %11111111
leddata [29] = %11111100 ' degrees c
leddata [30] = %11111100
leddata [31] = %11100011
leddata [32] = %10111101
leddata [33] = %10111101
leddata [34] = %10111101
leddata [35] = %11111111
OWOut DQ, 1, [$CC, $44]
OWOut DQ, 1, [$CC, $BE]
OWIn DQ, 2, [temperature.byte0, temperature.byte1]
Sign = temperature.15
temperature= ABS(temperature)
temperature=((temperature >> 4)*100) + ((temperature & $F) * 100 >> 4)
if sign then temperature= -temperature
tempA = temperature DIG 3
tempB = temperature DIG 2
tempC = temperature DIG 1
IF tempA = 0 THEN
for counter = 0 to 4
leddata [counter+8] = %11111111
next ' if 1st digit is 0 then skip so display dosnt display 09.5c
GOTO skipdigit ' it will display 9.5c instead
ENDIF
FOR counter = 0 TO 4
READ tempA*5+counter,leddata [counter+8] 'stores 1st digit in leddata locations 8,9,10,11,12
NEXT counter
skipdigit:
FOR counter = 0 TO 4
READ tempB*5+counter,leddata [counter+14] 'stores 2nd digit in leddata locations 14,15,16,17,18
NEXT
FOR counter = 0 TO 4
READ tempC*5+counter,leddata [counter+23] 'stores 3rd digit in leddata locations 23,24,25,26,27
NEXT
LOOPing:
FOR scroll = 0 TO 35
FOR scan = 0 TO 35
PORTb = 1
FOR counter = 0 TO 7
PORTa = leddata [counter]
PAUSE 1
PORTb = PORTb * 2
NEXT
NEXT
FOR counter = 0 TO 34
leddata [counter] = leddata [counter+1]
NEXT
NEXT
GOTO START
END
Maybe I put here tomorrow link to video (Y...tube).
Bookmarks