ibutton (onewire) and toggle led's

I am experimenting with an ibutton and want to toggle each alternative read of the ibutton so that one read activates a red led and then the next read activates a green led and so forth.

I am using millis to manage the led flashes and have got to the point of being able to flash the green led but I get no further. My guess is that maybe I need to somehow reinitialize the input pin to which the ibutton is connected?

If anyone can provide some pseudo code .... appreciated.

Readflag = FALSE. //Initialise

Loop start

Read ibutton

If correct number

If readflag false
Readflag = TRUE
Turn on red for time

Turn on green for time
Readflag = FALSE



I'll code that up when I have the time and post the result