On 6/10/2013 10:55 AM, Manu Abraham wrote: > On Mon, Jun 10, 2013 at 8:07 PM, Joe Wronski = wrote: >> On 6/10/2013 10:03 AM, Manu Abraham wrote: >>> One thing that I don't understand is, why he does this: " static >>> uint8_t old_AB =3D 0;" that would loose the previous state altogether, >>> wouldn't it ? >> No, the "=3D0" is only assigned when the static old_AB is allocated and >> initialized, after that, it retains it's value as set by the "old_AB =3D= " >> assignments in read_encoder() > > Please note the next line: > > > static uint8_t old_AB =3D 0; > /**/ > old_AB <<=3D 2; //remember previous state > > Once you initialize the variable to 0, then there is no way that it > can remember > the previous state. > I can't find my K&R book right now, but this should clear that idea up: In func() there is this line: static int x=3D 0; // x is initialized only once across three calls of = func() Joe W --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .