Log in

View Full Version : "was" command



ERMEGM
- 16th March 2011, 07:05
Hello All,

Minor brain cramp trying to figure out a small coding problem. Probably an easy solution, but having trouble seeing it.

I have a loop in my code that continuously monitors multiple inputs. These inputs are buttons, but the last one is an external input from an outside source.

The buttons can be individually programmed to do either A or B depending on what the last input is doing. Button 1 can be assigned to do task A when the last input is high and Button 2 can be assigned to do Task B when the last input is high (and swapped at some later time).

My dilemma is this: I have the code to say:

if lastinput = 1 then ' if input is on,
value = 1 ' then show on,
else
value = 0 ' else show off
endif

What I want to say now is:

If lastinput was 1 and is now 0 then go do this.

How do I go about doing a "was" command?

Thanks,
Tony

Ioannis
- 16th March 2011, 08:16
Maybe an edge triggered interrupt is what you need?

Ioannis

dhouston
- 16th March 2011, 10:27
If is <> was Then
was = is
If is = 1 Then
go do something
EndIf
EndIf