Hi. I believe that there is answer for my question somewhere in the forum, but I could not find it.
So I am trying to make some temperature display where I am using DS18B20 sensor and Hitachi 16x2 LCD display conected like it's shown in mannual 2 page 36. It displays a message from eeprom like in the example from the manuals, but when I try to display read data from DS18B20, it gives me a mess symbols. I understand that there is a problam in variable type, but I cannot figure it out how to make it work. Please have a look into my code. Most of it is copied from book and my not working part is to display the variables tents and singles. Please help.
So I am trying to make some temperature display where I am using DS18B20 sensor and Hitachi 16x2 LCD display conected like it's shown in mannual 2 page 36. It displays a message from eeprom like in the example from the manuals, but when I try to display read data from DS18B20, it gives me a mess symbols. I understand that there is a problam in variable type, but I cannot figure it out how to make it work. Please have a look into my code. Most of it is copied from book and my not working part is to display the variables tents and singles. Please help.
Thank you.#Picaxe 28x1
symbol button1 = pin1
symbol button2 = pin2
symbol temperature = b0
symbol system_var = b1
symbol system_var2 = b2
symbol system_var3 = b3
symbol system_var4 = b4
symbol hundreds = b5
symbol tents = b6
symbol singles = b7
symbol temp_var = b8
gosub init
pause 500
main:
pause 500
readtemp 0, temperature
bintoascii temperature, hundreds, tents, singles
gosub show_temp
debug
goto main
show_temp:
temp_var = 12 'hide cursor
gosub wrins
pause 10
temp_var = 1 'clear screen
gosub wrins
pause 10
temp_var = 128 'move to first line
gosub wrins
pause 10
temp_var = hundreds 'display hundreds on the screen
gosub wrcht
pause 15
temp_var = tents 'display tents
gosub wrcht
pause 15
temp_var = singles 'display singles
gosub wrcht
pause 15
return
wrcht: 'prints char on the screen (temp_var)
pins = temp_var & %11110000 | system_var3
pulsout 3, 1
pins = temp_var * %00010000 | system_var3
pulsout 3, 1
system_var3 = %00000100
return
wrins: 'LCD listens specific comands stored in temp_var
pins = temp_var & 240 'Mask the high nibble of system_var into b2.
pulsout 3,1 'Pulse the enable pin to send data.
system_var2 = temp_var * 16 'Put low nibble of system_var into b2.
pins = system_var2 & 240 'Mask the high nibble of b2
pulsout 3,1 'Pulse enable pin to send data.
high 2 'Back to character mode
return
init: 'resets and restores LCD screen
let pins = 0 'Clear all output lines
let system_var4 = 0 'Reset variable b4
pause 200 'Wait 200 ms for LCD to reset.
let pins = 48 'Set to 8-bit operation.
pulsout 3,1 'Send data by pulsing ‘enable’
pause 10 'Wait 10 ms
pulsout 3,1 'Send data again
pulsout 3,1 'Send data again
let pins = 32 'Set to 4-bit operation.
pulsout 3,1 'Send data.
pulsout 3,1 'Send data again.
let pins = 128 'Set multiple line operation
pulsout 3,1 'Send data.
let system_var = 14 'Screen on, cursor on instruction
gosub wrins 'Write instruction to LCD
return