How do i modify this code so it will show negative temperatures to?
I have been searching the forum but i canīt get it to work or is to dumb to understand..
Code:DEFINE OSC 20 DEFINE LCD_DREG PORTA 'Set LCD Data port DEFINE LCD_DBIT 0 'Set starting Data bit (0 or 4) if 4-bit bus DEFINE LCD_RSREG PORTA 'Set LCD Register Select port DEFINE LCD_RSBIT 4 'Set LCD Register Select bit DEFINE LCD_EREG PORTB 'Set LCD Enable port DEFINE LCD_EBIT 3 'Set LCD Enable bit DEFINE LCD_BITS 4 'Set LCD bus size (4 or 8 bits) DEFINE LCD_LINES 2 'Set number of lines on LCD DEFINE LCD_COMMANDUS 2000 'Set command delay time in us DEFINE LCD_DATAUS 100 'Set data delay time in us ADCON1 = 7 ' Set PORTA and PORTE to digital DQ Var PORTB.7 '1820 Datapin Temperature Var Word ' Temperature storage Count_remain Var Byte ' Count remaining Count_per_c Var Byte ' Count per degree C Mainloop: OWOut DQ, 1, [$CC, $44] ' Start temperature conversion Waitloop: OWIn DQ, 4, [count_remain] ' Check for still busy converting If count_remain = 0 Then waitloop OWOut DQ, 1, [$CC, $BE] ' Read the temperature OWIn DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE, Skip 4, count_remain, count_per_c] temperature = (((temperature >> 1) * 100) - 25) + (((count_per_c - count_remain) * 100) / count_per_c) Lcdout $fe, 1 LCDOut $fe, $c0, DEC(Temperature / 100), ".", DEC2 temperature, " C" Goto mainloop






Bookmarks