Need an expert to look at this piece of code (not my original, just bits cobbled together) and can you spot my mistake.
The timed switching works fine but the serial output to the LCD display doesn't at initial switch on.
If I disconnect the power supply lines to the display and re-connect then the display works in sympathy with
the switching. Any ideas please.
I'm running this on an AXE091 board and the display is an AXE133 budget LCD
The timed switching works fine but the serial output to the LCD display doesn't at initial switch on.
If I disconnect the power supply lines to the display and re-connect then the display works in sympathy with
the switching. Any ideas please.
Code:
picaxe08m2
'Repeating timer for blowdown.
'Picaxe Basic code for a repeating ON/OFF timer
'with the following ON and OFF timings:
'ON for 0 hours, 0 minutes, and 30 seconds.
'OFF for 0 hours, 0 minutes, and 20 seconds.
symbol relay = C.1
symbol relayb = C.2
debug ONmessage
debug OFFmessage
debug main
main:
'start ON cycle - energise relay.
high relay
gosub OFFmessage
'Pause for 30 seconds.
for b2 = 1 to 30
gosub pauseONEsecond
next b2
'Finish the ON cycle - de-energise the relay.
low relay
'Start the OFF cycle.
high relayb
gosub ONmessage
'Pause for 20 seconds.
for b1 = 1 to 20
gosub pauseONEsecond
next b1
'Finish relay2 cycle
low relayb
'Repeat the cycles
goto main
pauseONEhour:
'Pause for one hour.
for b0 = 0 to 0 'minutes
gosub pauseONEminute
next b0
return
pauseONEminute:
'Pause for one minute.
for b1 = 0 to 0 'seconds
gosub pauseONEsecond
next b1
return
pauseONEsecond:
'Pause for one second.
'1000ms (milliseconds) is one second.
pause 1000
return
ONmessage:
'pause 500 ; wait for display to initialise
serout B.0,N2400,(254,1) ; clear display
Pause 30
serout B.0,N2400,(254,128) ; move to start of first line
serout B.0,N2400,("MESSAGE 1") ; output text
serout B.0,N2400,(254,192) ; move to start of second line
serout B.0,N2400,("MESSAGE 2") ; output line 2 text
Pause 1000
return
OFFmessage:
'pause 500 ; wait for display to initialise
serout B.0,N2400,(254,1) ; clear display
Pause 30
serout B.0,N2400,(254,128) ; move to start of first line
serout B.0,N2400,("MESSAGE 1") ; output text
serout B.0,N2400,(254,192) ; move to start of second line
serout B.0,N2400,("MESSAGE 3") ; output line 2 text
Pause 1000
return
Last edited: