Hi everyone, I’m back again with another dopey question to what I hope is a straightforward solution.
I am using a little 12F675 and I want to switch to three or four different code sections from a Press to make Switch, but I want to write the selection to eeprom so as to recover the selection position after a power outage.
I have some code from the GCB help files which stores and recovers a byte from eeprom but I feel that I am still lacking the ability to elaborate this into something usable.
Hi everyone, I’m back again with another dopey question to what I hope is a straightforward solution.
I am using a little 12F675 and I want to switch to three or four different code sections from a Press to make Switch, but I want to write the selection to eeprom so as to recover the selection position after a power outage.
I have some code from the GCB help files which stores and recovers a byte from eeprom but I feel that I am still lacking the ability to elaborate this into something usable.
What I am looking for is
:
Press once - Do this
Press once again – Do that
And again – Do something different
And so on.
The code which works on a single output is:
#chip 12F675,4
#define Button GPIO.5
#define Light GPIO.0
Dir Button In
Dir Light Out
'Load saved status
EPRead 0, LightStatus
If LightStatus = 0 Then
Set Light Off
Else
Set Light On
End If
Do
'Wait for the button to be pressed
Wait While Button = On
Wait While Button = Off
'Toggle value, record
LightStatus = !LightStatus
EPWrite 0, LightStatus
'Update light
If LightStatus = 0 Then
Set Light Off
Else
Set Light On
End If
Loop
Once again your help would be greatly appreciated.
regards
Keith