Wednesday, July 06, 2005

Switch Var, counts the number of times the switch has been switched on

'Set Switch to RB0 and set LED to RB7
'this defines a variable for the switch
switchedOnVar var byte
'defining portb.0 as INPUT
input portb.0
'rest 500
pause 500
' start program with a half-second delay
main:
'If portb.0 is ON
if portb.0 = 1 then
'variable counts variable + 1 means, during switch on, program is running more and more. switchedOnVar = switchedOnVar + 1
endif'
'print it to serial out with linefeed and carriage return (10, 13)
serout2 portc.6, 16468, [DEC switchedOnVar, 13,10]
goto main

0 Comments:

Post a Comment

<< Home