there's probably 2 304 681 673 264 954 different way to do the same thing
WHILE/WEND
Code:
' Let's flash error message 3 times method 1
' ------------------------------------------
'
loop = 2
While Loop
lcdout $fe,$c0,"Error !"
pause 500
LCDOUT $fe,$c0," "
pause 500
loop = loop - 1
wend
FOR TO NEXT
Code:
' Let's flash error message 3 times method 2
' ------------------------------------------
'
for Loop=1 to 3
lcdout $fe,$c0,"Error !"
pause 500
LCDOUT $fe,$c0," "
pause 500
next
REPEAT/UNTIL
Code:
' Let's flash error message 3 times method 3
' ------------------------------------------
'
LOOP=0
REPEAT
lcdout $fe,$c0,"Error !"
pause 500
LCDOUT $fe,$c0," "
pause 500
LOOP=LOOP+1
UNTIL LOOP=3
IF THEN ELSE
Code:
' Let's flash error message 3 times method 4
' ------------------------------------------
'
LOOP=0
RedoLoop:
lcdout $fe,$c0,"Error !"
pause 500
LCDOUT $fe,$c0," "
pause 500
LOOP=LOOP+1
if loop !=3 then redoloop
Something to work with.. didn't test it.. should work
Code:
' I/O definition
' --------------
'
TRISB = %11000000
TRISC = %10111111
OPTION_REG.7 = 0 'enable pull-up resistor on PORTB
'Alias to I/O definition
'-----------------------
'
SW1 VAR PORTB.7
SW2 var PORTB.6
PiezoSPK var PORTC.6
Opto1 var PORTC.5
Opto2 var PORTC.4
Opto3 var PORTC.3
' LCD define
' ----------
'
define LCD_DREG PORTB ' Set data pin of LCD to
define LCD_DBIT 0 ' PORTB.0-PORTB.3
define LCD_RSREG PORTB ' Set RS bit of LCD to
define LCD_RSBIT 4 ' PORTB.4
define LCD_EREG PORTB ' Set E bit of LCD to
define LCD_EBIT 5 ' PORTB.5
' Variable definition
' -------------------
'
ActiveSwitch var byte
DelayVar var WORD
' Main Program
' ============
'
Start:
lcdout $fe,1, "Line1"
DELAYVAR=0
ReadSomething:
activeswitch=(PORTB & %11000000) | (PORTC & %00111000)
Select case activeswitch
case %01111000
Goto SW1Sub
case %10111000
GOto SW2Sub
case %11011000
goto Opto1Sub
case %11101000
goto Opto2Sub
case %11110000
goto Opto3Sub
end select
IF DELAYVAR<500 THEN
LCDOUT $FE,$C0,"Waiting !"
PAUSE 1
DELAYVAR=DELAYVAR + 1
ELSE
LCDOUT $FE,$C0," "
pause 1
delayvar=delayvar + 1
if delayvar = 1000 then delayvar = 0
endif
goto readsomething
SW1Sub:
lcdout $fe,1,"sw1"
pause 1000
goto start
SW2Sub:
lcdout $fe,1,"sw2"
pause 1000
goto start
Opto1Sub:
lcdout $fe,1,"Opto1"
pause 1000
goto start
Opto2Sub:
lcdout $fe,1,"Opto2"
pause 1000
goto start
Opto3Sub:
lcdout $fe,1,"Opto3"
pause 1000
goto start
Bookmarks