Serout command - display two lines?

Chickenman9806

New Member
Hi, I'v only been learning PICAXE for a few months so sorry if the question seems stupid...

I'm in the process of creating an alarm clock with two alarms for my GCSE electronics coursework and I'm using an LCD screen with the serout command. I have the code for the alarms and time working, but I was wondering is there a way to display two lines of data onto the screen and is there any time needed for the screen to load up etc?

I have had a look through the PICAXE manual and the datasheet for the screen I am using but havn't found anything.

Cheers,
Chickenman
 

Chickenman9806

New Member
Yeah its the only chip on my PCB.

Code:
main:
days_checks:	if b3=0 then goto monday
				if b3=1 then goto tuesday
				if b3=2 then goto wednesday
				if b3=3 then goto thursday
				if b3=4 then goto friday
				if b3=5 then goto saturday
				if b3=6 then goto sunday			
Checks:		if pin5=1 then goto set_hours
				if pin3=1 then goto show_alarm1
				if pin6=1 then goto show_alarm2
		goto alarm			
show_alarm1:	serout 7,N2400,(#b5,":",#b4)
alarm_set1:			if pin1=1 then goto alarm_hours1
		goto alarm1			
alarm_hours1:	let b4=b4+1
				if b4=25 then goto alarm_hours_reset1
		goto alarm			
alarm_hours_reset1:	let b4=0
alarm1:				if pin2=1 then goto alarm_minuites1
			goto alarm
				
alarm_minuites1:	let b5=b5+1
				if b5=60 then goto alarm_minuites_reset1
		goto alarm			
alarm_minuites_reset1:	let b5=0
		goto alarm			
show_alarm2:	serout 7,N2400,(#b7,":",#b6)
alarm_set2:			if pin1=1 then goto alarm_hours2
		goto alarm2		
alarm_hours2:	let b6=b6+1
				if b6=25 then goto alarm_hours_reset2
		goto alarm		
alarm_hours_reset2:	let b6=0
alarm2:				if pin2=1 then goto alarm_minuites2
			goto alarm		
alarm_minuites2:		let b7=b7+1
					if b7=60 then goto alarm_minuites_reset2
			goto alarm			
alarm_minuites_reset2:	let b7=0
alarm:				if pin0=1 then goto alarm_check1
					if pin7=1 then goto alarm_check2
			goto seconds		
alarm_check1:		if b3<5 and b4=b2 and b5=b1 then goto wake_up
			goto seconds			
alarm_check2:		if b3>4 and b6=b2 and b7=b1 then goto wake_up
			goto seconds
wake_up:			high 1
			goto seconds		
lock_time:			if pin5=1 then goto set_hours
			goto alarm		
set_hours:			if pin1=1 then goto add_hour
			goto set_minuites		
add_hour:			let b2=b2+1
			goto set_minuites		
set_minuites:		if pin2=1 then goto add_minuite
			goto set_days			
add_minuite:		let b1=b1+1
			goto set_days			
set_days:			if pin4=1 then goto add_day
			goto alarm		
add_day:			let b3=b3+1
			goto alarm		
seconds:	let b0=b0+1
			pause 1000
			if b0=60 then goto minuites
		goto main		
minuites:		let b0=0
				let b1=b1+1
				serout 7,N2400,(#b1,":",#b2)
			if b1=60 then goto hours
		goto main
hours:		let b1=0
				let b2=b2+1
			if b2=24 then goto days
		goto main		
days:			let b2=0
			let b3=b3+1
		goto main
'This was the bit I'm not sure on...		
				
monday:		serout 7, N2400, ("Monday   ")
		goto checks		
tuesday:		serout 7, N2400, ("Tuesday  ")
		goto checks		
wednesday:		serout 7, N2400, ("Wednesday")
		goto checks		
thursday:		serout 7, N2400, ("Thursday ")
		goto checks		
friday:		serout 7, N2400, ("Friday   ")
		goto checks		
saturday:		serout 7, N2400, ("Saturday ")
		goto checks		
sunday:		serout 7, N2400, ("Sunday   ")
		goto checks
Apologies if it seems a little 'primitive' :p
 

SilentScreamer

Senior Member
Try downloading just this, does it work?

Code:
serout 7,N2400,(254,1) &#8216;'blank the screen
pause 30 &#8216;'short delay to enable blank to complete
serout 7,N2400,(254,128,&#8220;Top Line&#8221;) &#8216;'top line message
serout 7,N2400,(254,192,&#8220;Bottom Line&#8221;) 'bottom line message
do
loop
 

Chickenman9806

New Member
I would try, but I'm afraid I don't have the screen or cable with me. They were left at school as I figured I wouldn't need them... :(
 

SilentScreamer

Senior Member
I understand now. I thought you where trying to use a LCD directly rather than a LCD with firmware.

To display "monday" on the top row and "hello" on the second.

Code:
serout 7,N2400,(254,1) 'Clear the LCD display
pause 30 'Allow the display to clear
serout 7,N2400,(254,128,"Monday") 'Set the top row's text
serout 7,N2400,(254,192,"Hello") 'Set the bottom row's text
Look on page 9 (or actual page 10) for more information.
 

Chickenman9806

New Member
Oh okay, sorry I wasn't very clear to start off with.
Many thanks!! :D:D

Just one more quick question, do I need to clear the screen every time the time changes or if I just put the serout would it just write over it?
 

SilentScreamer

Senior Member
Oh okay, sorry I wasn't very clear to start off with.
Many thanks!! :D:D

Just one more quick question, do I need to clear the screen every time the time changes or if I just put the serout would it just write over it?
To keep it simple, yes. Clear the screen then put the text on the top and bottom rows again. Look at the "gosub" command. It is like goto but you can use "return" to go back to the previous place in the code. So:

Main:
gosub Screen_Clear 'Clear the screen
gosub Screen_Monday 'Add the Monday text
pause 1000
goto Main

Screen_Clear:
serout 7,N2400,(254,1)
pause 30
return

Screen_Monday:
serout 7,N2400,(254,128,"Monday")
return
EDIT: Don't forget the "pause 30" after the screen clears. It isn't needed at any other time just as you clear it and it isn't noticeable.
 
Last edited:

SilentScreamer

Senior Member
I just looked at your circuit diagram and you need to remove the 4K7 resistors from the LCD connection. Look at page 8 (actual page 9) of the datasheet.
 

jaka

Member
If you clear the screen every time you will get flicker which is annoying. If you write to the same place each write then no need to clear. Time and date is ok, but with variables simply follow with a few spaces ie (#w0," ") where w0 can be any number from 0 to 65535.
 

SilentScreamer

Senior Member
If you clear the screen every time you will get flicker which is annoying. If you write to the same place each write then no need to clear. Time and date is ok, but with variables simply follow with a few spaces ie (#w0," ") where w0 can be any number from 0 to 65535.
The top line will wrap to the bottom line destroying the data on the bottom line.

EDIT: If its a clock then just put a pause 1000 in your code. Or even better only update the screen if the time has changed (an if statement that loops until a second has passed).
 
Last edited:

jaka

Member
"The top line will wrap to the bottom line destroying the data on the bottom line."

Unless you write more than 64 chraracters then this is not true. Also you would not write the programe so that you destroy other characters. I am assuming he is using a standard Hitachi chipset display.
 

SilentScreamer

Senior Member
"The top line will wrap to the bottom line destroying the data on the bottom line."

Unless you write more than 64 chraracters then this is not true. Also you would not write the programe so that you destroy other characters. I am assuming he is using a standard Hitachi chipset display.
Sods law dictates he will. And he is using the real time clock module or whatever its called.
 

jaka

Member
I agree. Looks like the AXE033, now I'v looked at the thread again. Can get confusing having to write the i2cslave command every time you change from LCD to RTC.
 
Top