Serial LCD not obeying commands to start at 0,0 and 1,0
winston
Posts: 2
I have had a heck of a time trying to get a serial LCD connected to a BOE and BS2 to place the characters where I want them on the LCD. I just need to be able to have the word "Humidity" displayed at 0,0 and then the actual value of humidity displayed immediately after that. It keeps writing and wrapping instead of placing them at the same place on the LCD and overwriting with new values. Here is my code:
Any ideas? I have changed the "LcdLine1", and "LcdLine2" constants to hex and back with no difference in the result.
' {$STAMP BS2} ' {$PBASIC 2.5} ' RelativeHumidityReading.bs2 ' Displays relative humidity in the Debug Terminal or the Parallax Serial LCD. index VAR Word Humaverage VAR Word LCD PIN 0 ' Serial output to LCD time VAR Word humidity VAR Word LcdBaud CON 16780 ' Baud rate of LCD RHconstant CON 11398 ' Relative Humidity Constant * 10 LcdCls CON $0C ' Clear LCD (use PAUSE 5 after) LcdCR CON $0D ' Move pos 0 of next line LcdBLon CON $11 ' Backlight on LcdBLoff CON $12 ' Backlight off LcdOff CON $15 ' LCD off LcdOn1 CON $16 ' LCD on; cursor off, blink off LcdLine1 CON 128 ' Move to line 0, position 0 LcdLine2 CON 148 ' Move to line 1, position 5 HIGH Lcd ' Setup serial output pin PAUSE 100 SEROUT Lcd, LcdBaud, [LcdOn1] ' Initialize LCD PAUSE 250 'SEROUT Lcd, LcdBaud, [LcdBLon] ' Turn Backlight on 'PAUSE 5 SEROUT Lcd, LcdBaud, [LcdCls] ' Clear LCD PAUSE 5 DO FOR index = 1 TO 100 HIGH 7 PAUSE 5 RCTIME 7, 1, time 'time = time * 10 humidity = ((time * 10) - 11398)/24 'humidity = (time - RHconstant) / 24 IF index = 1 THEN Humaverage = humidity *4 Humaverage = Humaverage */192 + humidity NEXT Humaverage = Humaverage/4 ' Debug Display: DEBUG HOME, "Rel. Humidity = ", DEC humidity, "%",CLREOL ' LCD Display: SEROUT Lcd, LcdBaud, [LcdLine1, "Humidity",LcdLine2, DEC Humaverage, "%" ] PAUSE 100 LOOP
Any ideas? I have changed the "LcdLine1", and "LcdLine2" constants to hex and back with no difference in the result.
Comments
Change
to
Set the LCD for 9600 baud (switch 1= off, switch 2= on)
I couldn't duplicate your problem exactly, but with these changes it worked fine for me.
Doc.