unsigned char i = 1; P1 = 1; while (1) { if (hasKey()) i = 1 << GetKey(); if (P1 > i) while ((P1 >>= 1) > i) Delay(); if (P1 < i) while ((P1 <<= 1) < i) Delay(); }