Hi all

I have had a bit of a blonde moment and wonder if anyone could help me,

Thanks...

Can anyone suggest a small bit of self contained code I can add at the end of my existing code, That will give me a toggled flip-flop output.

EG, gp0 i/p (triggered high to low via push button)
gp1 o/p (low at switch on)
gp2 o/p (high at switch on)

When i/p triggered the o/p's swap over and latch in that state until the button is pressed again, after it will then return back to the original state.

Also how difficult is it to get the pic to remember its last state after a power up/down

This is a test program I tried to get working, before modding and inserting into my existing code.


' Define Hardware
' ---------------
InputTrigger var GPIO.2 ' Input normally HIGH, goes LOW to Trigger
OutputLine0 var GPIO.0 ' Normally LOW, goes HIGH when triggered
OutputLine1 var GPIO.1 ' Normally LOW, goes HIGH when triggered
'
' Initialise PIC
' --------------
Reset:
TRISIO=%00000100 ' Preset I/O
CMCON=%00000111 ' Disable Comparators
ANSEL=%00000000 ' Disable ADC
pause 200
HIGH OutputLine0 ' Set output
LOW outputline1 ' Set output

if outputline0=0 then outputline1=1 (these are the two lines i am having)
if outputline0=1 then ouputline1=0 ( problems with )

' Main Program Loop
' -----------------
Loop:
'
'
' Test for Trigger
' ----------------
If InputTrigger=0 then ' Test for Trigger
toggle OutputLine0 ' Enable Output

endif
Goto Loop