I try to use code from post #1 to my thermometer with 16F628A, DS18B20 and LED display ( like in : http://melabs.com/resources/articles/ledart.htm fig.6). To another topic, I receive one working code, from one user (thanks !).
But, I am still disappointed, because MY code don't work. Please, what's wrong with him ? Thank you !
Code:@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_ON, MCLR_OFF, LVP_OFF, CPD_OFF, PROTECT_OFF TRISA= %11110000 ' RA0..3=Outputs RA4=Input TRISB= %00000000 ' RB0..RB7=Outputs CMCON=7 ' Disable comparators DQ VAR PORTA.4 DS18B20_12bit CON %01111111 ' 750ms, 0.0625°C I VAR BYTE SIGN VAR BIT TEMPERATURE VAR WORD ; TEMPERATURE REGISTER n var byte segments var portb digits var porta value var word MAINloop : OWOUT DQ ,1,[$CC,$44] WaitLoop: While not DQ Wend OWOUT DQ ,1,[$CC,$BE] OWIN DQ ,2,[TEMPERATURE.LOWBYTE , TEMPERATURE.HIGHBYTE] IF TEMPERATURE.15 = 1 THEN TEMPERATURE = (65535 - TEMPERATURE) + 1 SIGN = 1 ELSE SIGN = 0 ENDIF value = (TEMPERATURE * 10)/16 gosub display goto mainloop ' Subroutine to send the number (0 - 9999) in Value to LEDs display: For i = 0 To 3 ' Loop through 4 digits n = value Dig i ' Get digit to display GoSub display1 ' Display the digit ' Leave it on 2 millisecondS Next i ' Do next digit Return ' Surboutine to display one digit on LED ' i = digit number ' n = number to display display1: 'Digits = $ff ' All digits off to prevent ghosting ' Convert binary number in n to segments for LED Lookup n, [$40, $79, $24, $30, $19, $12, $02, $78, $00, $18,$7f], Segments ' logic low complements ' Set digit pin i to 0 (on) and the rest of the pins to 1 (off) Digits = ~Dcd i Pause 1 'Increase to make digits brighter and flicker worse Return end




Bookmarks