Hello all,
My code is
Code is for a push button on input which is high always.
When i press the button for less than 5 sec it should light LED on PORTC.5
When i press the button for more than 5 sec it should light LED on PORTC.2
The code works perfectly but is there a simpler way to do it ? to save code space
cheers
Mastero
My code is
Code:
'Definition of Input ports
Symbol sw = PORTB.5 'input
Symbol led = PORTC.5
Symbol led1 = PORTC.2
led = 0
led = 0
k = False
y = 0
x = 0
'********** Main loop ******************
menu:
Gosub check_switch
Goto menu
End
check_switch:
If sw = 0 Then
k = True
Endif
If sw = 1 Then
If k = True Then
If x = 0 Then
led = 1
WaitMs 1
led = 0
k = False
y = 0
Endif
Endif
Endif
If sw = 0 Then
If k = True Then
If x = 0 Then
y = y + 1
If y = 10 Then
led1 = 1
WaitMs 1
led1 = 0
x = 1
Endif
Endif
Endif
Endif
If x = 1 Then
If sw = 1 Then
k = False
y = 0
x = 0
Endif
Endif
Return
Code is for a push button on input which is high always.
When i press the button for less than 5 sec it should light LED on PORTC.5
When i press the button for more than 5 sec it should light LED on PORTC.2
The code works perfectly but is there a simpler way to do it ? to save code space
cheers
Mastero
Last edited by a moderator: