.... that had 1 switch as input, say on RB0. Then each time the switch is pressed a different LED routine is actioned.
So for example:
1st switch push, LED on RC0 stays on
2nd switch push, LED on RC1 blinks
3rd switch push, LEDs on RC2 and RC3 'wink'
As i don't know what 'wink' mean... this is something to help you to start...
There's so many different way but... Never tested but should work.
Code:
ADCON1=7 'disable analog to digital converter
OPTION_REG.7=0 'enable pull-up resistor on PORTb
PushButton var PORTB.0 ' pushButton connected between RB0
' and ground
Led1 VAR PORTC.0 ' All LEDs
Led2 VAR PORTC.1 ' Connected between
Led3 VAR PORTC.2 ' RC pins and ground
Led4 VAR PORTC.3 ' via resistor
PushHowManyTimes var byte
Delay VAR BYTE
Delay=0
PushHowManyTimes=0
start:
While pushbutton ' do the specific task untill pushbutton
' is pressed
branch PushHowManyTimes , [Start,StayOn,Blink]
wend
PushHowManytimes=PushHowManytimes+1 ' Changing task
if PushHowManytimes=3 then PushHowManytimes=1
while pushbutton=0 ' waiting untill pushbutton is release
wend
pause 50 ' debounce time
goto start
StayOn:
High PORTC.0
goto start
Blink:
Low PORTC.0
If delay<50 then
High PORTC.1
else
If delay<100 then
low PORTC.1
else
delay=0
endif
endif
pause 10
Delay=delay+1
goto start
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks